From b820a75ec5a9269bfc4cad80fedb3e2c005adc70 Mon Sep 17 00:00:00 2001 From: Jacob Fletcher Date: Fri, 7 Feb 2025 09:15:18 -0500 Subject: [PATCH] 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. --- .../ui/src/elements/ListControls/index.tsx | 1 - test/admin/e2e/list-view/e2e.spec.ts | 29 +++++++++++++++---- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/packages/ui/src/elements/ListControls/index.tsx b/packages/ui/src/elements/ListControls/index.tsx index faf3bb7432..c0a370ffd1 100644 --- a/packages/ui/src/elements/ListControls/index.tsx +++ b/packages/ui/src/elements/ListControls/index.tsx @@ -97,7 +97,6 @@ export const ListControls: React.FC = (props) => { useEffect(() => { if (hasWhereParam.current && !query?.where) { - setVisibleDrawer(undefined) hasWhereParam.current = false } else if (query?.where) { hasWhereParam.current = true diff --git a/test/admin/e2e/list-view/e2e.spec.ts b/test/admin/e2e/list-view/e2e.spec.ts index ca1b39c2d1..e84fbb2448 100644 --- a/test/admin/e2e/list-view/e2e.spec.ts +++ b/test/admin/e2e/list-view/e2e.spec.ts @@ -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)) @@ -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)/) }) @@ -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`, )