Skip to content

Commit e2b4775

Browse files
committed
fix: expand filtered catalog sections without persisting state
- Render matching sections expanded while search filter is active - Keep persisted collapsed state untouched during search-driven expansion - Avoid chip navigation state writes while filtering - Add Playwright regression coverage for non-persistent search expansion Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent 47789b5 commit e2b4775

2 files changed

Lines changed: 63 additions & 7 deletions

File tree

playwright/e2e/policy-workbench-catalog-controls.spec.ts

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,3 +252,50 @@ test('catalog collapse and per-category expanded state persist after reload', as
252252

253253
expect(errorCollector.all(), 'No JavaScript errors should happen while persisting catalog state').toEqual([])
254254
})
255+
256+
test('search temporarily expands result sections without persisting section state', async ({ page }) => {
257+
const adminUser = process.env.NEXTCLOUD_ADMIN_USER ?? 'admin'
258+
const adminPassword = process.env.NEXTCLOUD_ADMIN_PASSWORD ?? 'admin'
259+
260+
await login(page.request, adminUser, adminPassword)
261+
await setUserLanguage(page.request, adminUser, 'en')
262+
263+
await page.setViewportSize({ width: 1365, height: 950 })
264+
265+
const errorCollector = collectJavascriptErrors(page)
266+
267+
await page.goto('./settings/admin/libresign')
268+
269+
const searchField = page.getByRole('textbox', { name: /Search settings/i }).first()
270+
await expect(searchField).toBeVisible({ timeout: 20000 })
271+
272+
const collapseButton = await getCatalogCollapseButton(page)
273+
if (/Collapse settings categories/i.test((await collapseButton.getAttribute('aria-label')) ?? '')) {
274+
await Promise.all([
275+
waitForUserConfigSave(page, 'policy_workbench_catalog_collapsed'),
276+
collapseButton.click(),
277+
])
278+
}
279+
await expect(collapseButton).toHaveAttribute('aria-label', /Expand settings categories/i)
280+
281+
const collapsedStateSaves: string[] = []
282+
page.on('request', (request) => {
283+
if (request.method() === 'PUT' && request.url().includes('/apps/libresign/api/v1/account/config/policy_workbench_category_collapsed_state')) {
284+
collapsedStateSaves.push(request.url())
285+
}
286+
})
287+
288+
await searchField.fill('signing')
289+
290+
const signingWorksToggle = page.locator('#policy-category-how-signing-works .policy-workbench__category-toggle').first()
291+
await expect(signingWorksToggle).toBeVisible({ timeout: 10000 })
292+
await expect(signingWorksToggle).toHaveAttribute('aria-expanded', 'true')
293+
294+
await page.waitForTimeout(400)
295+
expect(collapsedStateSaves, 'Search-driven expansion must not persist section collapsed state').toHaveLength(0)
296+
297+
await searchField.fill('')
298+
await expect(signingWorksToggle).toHaveAttribute('aria-expanded', 'false')
299+
300+
expect(errorCollector.all(), 'No JavaScript errors should happen while showing filtered results').toEqual([])
301+
})

src/views/Settings/PolicyWorkbench/Catalog/Catalog.vue

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,18 +98,18 @@
9898
type="button"
9999
class="policy-workbench__category-toggle"
100100
:aria-controls="`policy-category-content-${category.key}`"
101-
:aria-expanded="String(catalogState.isCategoryExpanded(category.key))"
101+
:aria-expanded="String(isCategoryExpandedForRender(category.key))"
102102
@click="catalogState.toggleCategoryCollapsed(category.key)">
103103
<NcIconSvgWrapper
104104
class="policy-workbench__category-toggle-icon"
105-
:path="catalogState.isCategoryExpanded(category.key) ? mdiChevronUp : mdiChevronDown"
105+
:path="isCategoryExpandedForRender(category.key) ? mdiChevronUp : mdiChevronDown"
106106
:size="18" />
107107
<span class="policy-workbench__category-title">{{ category.label }}</span>
108108
</button>
109109
</h3>
110110
<div
111111
:id="`policy-category-content-${category.key}`"
112-
v-show="catalogState.isCategoryExpanded(category.key)"
112+
v-show="isCategoryExpandedForRender(category.key)"
113113
class="policy-workbench__category-content">
114114
<div class="policy-workbench__settings-grid">
115115
<article
@@ -175,18 +175,18 @@
175175
type="button"
176176
class="policy-workbench__category-toggle"
177177
:aria-controls="`policy-category-content-${category.key}`"
178-
:aria-expanded="String(catalogState.isCategoryExpanded(category.key))"
178+
:aria-expanded="String(isCategoryExpandedForRender(category.key))"
179179
@click="catalogState.toggleCategoryCollapsed(category.key)">
180180
<NcIconSvgWrapper
181181
class="policy-workbench__category-toggle-icon"
182-
:path="catalogState.isCategoryExpanded(category.key) ? mdiChevronUp : mdiChevronDown"
182+
:path="isCategoryExpandedForRender(category.key) ? mdiChevronUp : mdiChevronDown"
183183
:size="18" />
184184
<span class="policy-workbench__category-title">{{ category.label }}</span>
185185
</button>
186186
</h3>
187187
<div
188188
:id="`policy-category-content-${category.key}`"
189-
v-show="catalogState.isCategoryExpanded(category.key)"
189+
v-show="isCategoryExpandedForRender(category.key)"
190190
class="policy-workbench__category-content">
191191
<div class="policy-workbench__settings-list" role="list">
192192
<article
@@ -1063,8 +1063,17 @@ function toggleCatalogCollapsed() {
10631063
catalogState.toggleCatalogCollapsed()
10641064
}
10651065
1066+
function isCategoryExpandedForRender(category: RealPolicySettingCategory): boolean {
1067+
if (hasActiveFilter.value) {
1068+
// Search results must be visible even when the persisted state is collapsed.
1069+
return true
1070+
}
1071+
1072+
return catalogState.isCategoryExpanded(category)
1073+
}
1074+
10661075
function handleCategoryChipNavigation(category: RealPolicySettingCategory, event?: MouseEvent) {
1067-
if (!catalogState.isCategoryExpanded(category)) {
1076+
if (!hasActiveFilter.value && !catalogState.isCategoryExpanded(category)) {
10681077
catalogState.toggleCategoryCollapsed(category)
10691078
}
10701079

0 commit comments

Comments
 (0)