fix(ui): keep active settings group expanded

Ensure the group for the current page remains open despite persisted collapse state, with regression coverage.
This commit is contained in:
Andras Bacsai
2026-09-18 12:24:32 +02:00
parent ccc2a3fd57
commit 9346f5f4af
2 changed files with 15 additions and 3 deletions
+7 -3
View File
@@ -34,12 +34,16 @@ export function initializeSettingsSidebarAccordionComponent() {
this.groups = stored && typeof stored === 'object' ? stored : {};
},
isOpen(group) {
// Explicit user choice wins (so the active group can be collapsed too);
// otherwise only the active group is open by default.
// The current page must stay visible, even when this group was
// previously stored as collapsed on another page.
if (group === this.activeGroup) {
return true;
}
if (Object.prototype.hasOwnProperty.call(this.groups, group)) {
return this.groups[group];
}
return group === this.activeGroup;
return false;
},
toggle(group) {
this.groups = { ...this.groups, [group]: !this.isOpen(group) };
@@ -58,3 +58,11 @@ it('registers the accordion Alpine provider', function () {
expect(file_get_contents(base_path('resources/js/settings-sidebar-accordion.js')))
->toContain("Alpine.data('settingsSidebarAccordion'");
});
it('keeps the group for the active page open', function () {
$accordion = file_get_contents(base_path('resources/js/settings-sidebar-accordion.js'));
expect($accordion)
->toContain('if (group === this.activeGroup)')
->toContain('return true;');
});