Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

fix(ui): keep active settings group expanded

Andras Bacsai9346f5f4af2b
diff --git a/resources/js/settings-sidebar-accordion.js b/resources/js/settings-sidebar-accordion.js
index 3c97a91bf8..fc62865f0b 100644
--- a/resources/js/settings-sidebar-accordion.js
+++ b/resources/js/settings-sidebar-accordion.js
@@ -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) };
diff --git a/tests/Feature/SettingsSidebarAccordionTest.php b/tests/Feature/SettingsSidebarAccordionTest.php
index 698e5643cf..85ff5dabf3 100644
--- a/tests/Feature/SettingsSidebarAccordionTest.php
+++ b/tests/Feature/SettingsSidebarAccordionTest.php
@@ -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;');
+});