Skip to content

Commit b820a75

Browse files
authored
fix(ui): removing final condition closes where builder (#11032)
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.
1 parent 49d94d5 commit b820a75

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed

packages/ui/src/elements/ListControls/index.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ export const ListControls: React.FC<ListControlsProps> = (props) => {
9797

9898
useEffect(() => {
9999
if (hasWhereParam.current && !query?.where) {
100-
setVisibleDrawer(undefined)
101100
hasWhereParam.current = false
102101
} else if (query?.where) {
103102
hasWhereParam.current = true

test/admin/e2e/list-view/e2e.spec.ts

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,28 @@ describe('List View', () => {
296296
})
297297

298298
describe('filters', () => {
299+
test('should not close where builder when clearing final condition', async () => {
300+
await page.goto(postsUrl.list)
301+
await openListFilters(page, {})
302+
await page.locator('.where-builder__add-first-filter').click()
303+
await page.locator('.condition__field').click()
304+
await page.locator('.rs__option', { hasText: exactText('Relationship') }).click()
305+
await page.locator('.condition__operator').click()
306+
await page.locator('.rs__option', { hasText: exactText('equals') }).click()
307+
const valueInput = await page.locator('.condition__value')
308+
await valueInput.click()
309+
await valueInput.locator('.rs__option').first().click()
310+
311+
await page.waitForURL(/&where/)
312+
313+
await page.locator('.condition__actions .btn.condition__actions-remove').click()
314+
315+
await page.waitForURL(/^(?!.*&where)/)
316+
317+
const whereBuilder = page.locator('.list-controls__where.rah-static.rah-static--height-auto')
318+
await expect(whereBuilder).toBeVisible()
319+
})
320+
299321
test('should respect base list filters', async () => {
300322
await page.goto(baseListFiltersUrl.list)
301323
await page.waitForURL((url) => url.toString().startsWith(baseListFiltersUrl.list))
@@ -382,8 +404,7 @@ describe('List View', () => {
382404

383405
await page.waitForURL(/&where/)
384406

385-
const valueInput = page.locator('.condition__value')
386-
const removeButton = valueInput.locator('.clear-indicator').click()
407+
page.locator('.condition__value').locator('.clear-indicator').click()
387408

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

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

0 commit comments

Comments
 (0)