fix(ui): let revealed panels own their side and keep Cockpit's left strip

A panel a feature opens (Street Level's viewer, a selected radio station)
now becomes its side's open panel instead of being collapsed again by the
next layout pass. Cockpit keeps showing its collapsed Data Layers strip,
which Cyber's Cockpit layout aligns to, and Cyber's focus layout no longer
re-shows collapsed left panels. Both sidebars share one accordion helper.
This commit is contained in:
Sameh Khamis committed 2026-10-30 16:41:29 -07:00
1 parent 2035c767ce
commit eed7657516
9 files changed
+124 -58

No files matched your search

+41
View File
@@ -0,0 +1,41 @@
/**
* Keep one side panel open on desktop, and on phones put back the collapse
* this applied, since a sheet shows several panels at once. The owner is the
* most recently opened panel, then the one holding keyboard focus, then the
* first. `accordion-collapsed` marks the collapse as presentation only, so
* saved and shared preferences still report the panel as the user left it.
* @param {object} options
* @param {HTMLElement[]} options.panels The side's laid-out panels.
* @param {boolean} options.enabled Whether the one-panel rule applies.
* @param {string} [options.preferredPanelId] Most recently opened panel.
* @param {Document} [options.documentRef] Document supplying keyboard focus.
* @param {Function} options.onCollapse Update a panel's disclosure chrome.
*/
export function settleSideAccordion({
panels,
enabled,
preferredPanelId,
documentRef,
onCollapse,
}) {
if (!enabled) {
for (const panel of panels) {
if (!panel.classList.contains('accordion-collapsed')) continue;
panel.classList.remove('collapsed', 'accordion-collapsed');
onCollapse(panel);
}
return;
}
const expanded = panels.filter(
(panel) => !panel.classList.contains('collapsed'),
);
const owner =
expanded.find((panel) => panel.id === preferredPanelId) ||
expanded.find((panel) => panel.contains(documentRef?.activeElement)) ||
expanded[0];
for (const panel of expanded) {
if (panel === owner) continue;
panel.classList.add('collapsed', 'accordion-collapsed');
onCollapse(panel);
}
}