Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: let navigation popovers handle Escape before the sidebar (#6909)

[._.]/ Adam Eivy4ebd75969472
diff --git a/client/src/components/Layout.jsx b/client/src/components/Layout.jsx
index 4448b116fe..c11432a771 100644
--- a/client/src/components/Layout.jsx
+++ b/client/src/components/Layout.jsx
@@ -1234,7 +1234,8 @@ export default function Layout() {
inert={!desktopNav && !mobileNavActive}
aria-hidden={!desktopNav && !mobileNavActive ? true : undefined}
onKeyDown={(event) => {
- if (mobileNavActive && event.key === 'Escape' && !event.defaultPrevented) {
+ // Portaled child popovers own their Escape dismissal.
+ if (mobileNavActive && event.key === 'Escape' && !event.defaultPrevented && event.currentTarget.contains(event.target)) {
event.stopPropagation();
setMobileOpen(false);
}
diff --git a/client/src/components/Layout.test.jsx b/client/src/components/Layout.test.jsx
index 24352f04ba..5f2f3215eb 100644
--- a/client/src/components/Layout.test.jsx
+++ b/client/src/components/Layout.test.jsx
@@ -36,7 +36,13 @@ vi.mock('../hooks/useNotifications', () => ({
// --- Theme context: Layout reads `theme.mode` for the day/night toggle. ---
vi.mock('./ThemeContext', () => ({
- useThemeContext: () => ({ theme: { mode: 'night', label: 'Test', pair: null }, toggleMode: vi.fn() }),
+ useThemeContext: () => ({
+ theme: { mode: 'night', label: 'Test', pair: null },
+ themeId: 'test',
+ themeList: [{ id: 'test', label: 'Test', family: 'classic', shortLabel: 'Test', density: 'comfortable' }],
+ setTheme: vi.fn(),
+ toggleMode: vi.fn(),
+ }),
}));
// --- Heavy child widgets: render nothing so they don't open sockets / fetch. ---
@@ -627,6 +633,25 @@ describe('Layout — keyboard navigation shell', () => {
expect(sidebar).toHaveAttribute('inert');
});
+ it('dismisses a portaled theme picker before closing its mobile sidebar', async () => {
+ desktopMedia.matches = false;
+ const { container } = await renderLayout();
+ const sidebar = container.querySelector('#app-sidebar');
+ const opener = screen.getByRole('button', { name: 'Open navigation menu' });
+ fireEvent.click(opener);
+ const themeButton = within(sidebar).getByRole('button', { name: 'Switch theme. Current theme: Test' });
+ fireEvent.click(themeButton);
+ const option = screen.getByRole('menuitemradio', { name: /Test/ });
+ expect(option).toHaveFocus();
+ fireEvent.keyDown(option, { key: 'Escape' });
+ expect(screen.queryByRole('menu')).not.toBeInTheDocument();
+ expect(themeButton).toHaveFocus();
+ expect(opener).toHaveAttribute('aria-expanded', 'true');
+ fireEvent.keyDown(themeButton, { key: 'Escape' });
+ expect(opener).toHaveFocus();
+ expect(sidebar).toHaveAttribute('inert');
+ });
+
it('keeps desktop navigation accessible and releases the mobile trap on a breakpoint change', async () => {
const { container } = await renderLayout();
const sidebar = container.querySelector('#app-sidebar');