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: Escape in the command palette no longer closes the underlying drawer (#9530)

Adam Eivy0f45369c8fb2
diff --git a/client/src/components/CmdKSearch.jsx b/client/src/components/CmdKSearch.jsx
index 5fb9f492a0..b5454a995d 100644
--- a/client/src/components/CmdKSearch.jsx
+++ b/client/src/components/CmdKSearch.jsx
@@ -407,6 +407,9 @@ export default function CmdKSearch() {
const item = activeResult;
if (item) dispatchCommand(item);
} else if (e.key === 'Escape') {
+ // Consume it so an underlying Drawer's window-level Esc listener doesn't also close.
+ e.preventDefault();
+ e.stopPropagation();
close();
}
};
diff --git a/client/src/components/CmdKSearch.test.jsx b/client/src/components/CmdKSearch.test.jsx
index 293fa9b332..6db72f3f31 100644
--- a/client/src/components/CmdKSearch.test.jsx
+++ b/client/src/components/CmdKSearch.test.jsx
@@ -1,3 +1,4 @@
+import { useState } from 'react';
import { beforeEach, describe, expect, it, vi } from 'vitest';
import { act, fireEvent, render, screen, waitFor, within } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
@@ -31,6 +32,7 @@ vi.mock('./ui/Toast', () => ({ default: toast }));
import { __resetInstanceFeatureCache } from '../hooks/useInstanceFeatures.js';
import CmdKSearch from './CmdKSearch.jsx';
+import Drawer from './Drawer.jsx';
const NAV = [
{ id: 'nav.dashboard', path: '/', label: 'Dashboard', section: 'Home', aliases: [], keywords: [] },
@@ -353,6 +355,34 @@ describe('CmdKSearch dialog accessibility', () => {
expect(opener).toHaveFocus();
});
+ it('closes only the palette on the first Escape when opened over a Drawer', async () => {
+ const user = userEvent.setup();
+ const Harness = () => {
+ const [open, setOpen] = useState(true);
+ return (
+ <MemoryRouter>
+ <Drawer open={open} onClose={() => setOpen(false)} title="Settings">
+ <button type="button">Drawer control</button>
+ </Drawer>
+ <CmdKSearch />
+ </MemoryRouter>
+ );
+ };
+ render(<Harness />);
+ const control = screen.getByRole('button', { name: 'Drawer control' });
+ control.focus();
+ await user.keyboard('{Meta>}k{/Meta}');
+ await screen.findByRole('dialog', { name: 'Command palette' });
+
+ await user.keyboard('{Escape}');
+ await waitFor(() => expect(screen.queryByRole('dialog', { name: 'Command palette' })).not.toBeInTheDocument());
+ expect(screen.getByRole('dialog', { name: 'Settings' })).toBeInTheDocument();
+ expect(control).toHaveFocus();
+
+ await user.keyboard('{Escape}');
+ await waitFor(() => expect(screen.queryByRole('dialog', { name: 'Settings' })).not.toBeInTheDocument());
+ });
+
it('opens when the shared command-palette event is dispatched', async () => {
render(
<MemoryRouter>