Skip to content

Commit

Permalink
fix(ui): removing final condition closes where builder (#11032)
Browse files Browse the repository at this point in the history
When filtering the list view, removing the final condition from the
query closes the "where" builder entirely. This forces the user to
re-open the filter controls and begin adding conditions from the start.
  • Loading branch information
jacobsfletch authored Feb 7, 2025
1 parent 49d94d5 commit b820a75
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
1 change: 0 additions & 1 deletion packages/ui/src/elements/ListControls/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ export const ListControls: React.FC<ListControlsProps> = (props) => {

useEffect(() => {
if (hasWhereParam.current && !query?.where) {
setVisibleDrawer(undefined)
hasWhereParam.current = false
} else if (query?.where) {
hasWhereParam.current = true
Expand Down
29 changes: 24 additions & 5 deletions test/admin/e2e/list-view/e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,28 @@ describe('List View', () => {
})

describe('filters', () => {
test('should not close where builder when clearing final condition', async () => {
await page.goto(postsUrl.list)
await openListFilters(page, {})
await page.locator('.where-builder__add-first-filter').click()
await page.locator('.condition__field').click()
await page.locator('.rs__option', { hasText: exactText('Relationship') }).click()
await page.locator('.condition__operator').click()
await page.locator('.rs__option', { hasText: exactText('equals') }).click()
const valueInput = await page.locator('.condition__value')
await valueInput.click()
await valueInput.locator('.rs__option').first().click()

await page.waitForURL(/&where/)

await page.locator('.condition__actions .btn.condition__actions-remove').click()

await page.waitForURL(/^(?!.*&where)/)

const whereBuilder = page.locator('.list-controls__where.rah-static.rah-static--height-auto')
await expect(whereBuilder).toBeVisible()
})

test('should respect base list filters', async () => {
await page.goto(baseListFiltersUrl.list)
await page.waitForURL((url) => url.toString().startsWith(baseListFiltersUrl.list))
Expand Down Expand Up @@ -382,8 +404,7 @@ describe('List View', () => {

await page.waitForURL(/&where/)

const valueInput = page.locator('.condition__value')
const removeButton = valueInput.locator('.clear-indicator').click()
page.locator('.condition__value').locator('.clear-indicator').click()

await page.waitForURL(/^(?!.*&where)/)
})
Expand Down Expand Up @@ -662,10 +683,8 @@ describe('List View', () => {
condition2?.locator('.rs__menu-list:has-text("Disable List Filter Text")'),
).toBeHidden()
})
})

describe('WhereBuilder', () => {
test('should render where builder', async () => {
test('should properly paginate many documents', async () => {
await page.goto(
`${with300DocumentsUrl.list}?limit=10&page=1&where%5Bor%5D%5B0%5D%5Band%5D%5B0%5D%5BselfRelation%5D%5Bequals%5D=null`,
)
Expand Down

0 comments on commit b820a75

Please sign in to comment.