mirror of
https://github.com/coollabsio/coolify.git
synced 2026-09-26 17:30:46 -04:00
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:
@@ -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;');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user