From fd18e8db3006aab37ae5ed83abfc34d1432a58d0 Mon Sep 17 00:00:00 2001 From: David Montero Crespo Date: Mon, 3 Aug 2026 03:01:54 +0200 Subject: [PATCH] fix(libraries): Escape closes the manager, the way out everyone tries --- .../components/simulator/LibraryManagerModal.tsx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/frontend/src/components/simulator/LibraryManagerModal.tsx b/frontend/src/components/simulator/LibraryManagerModal.tsx index 9d771266..97df229b 100644 --- a/frontend/src/components/simulator/LibraryManagerModal.tsx +++ b/frontend/src/components/simulator/LibraryManagerModal.tsx @@ -140,6 +140,20 @@ export const LibraryManagerModal: React.FC = ({ isOpen if (isOpen) fetchInstalled(); }, [isOpen, fetchInstalled]); + // Escape closes it, like any dialog. The overlay already closes on a + // backdrop click, but the toolbar button that OPENED this sits underneath + // the overlay — so someone who installs a library and reaches for it to get + // back to their sketch clicks a button that cannot be hit, and the editor + // reads as frozen. Escape is the exit everyone tries next. + useEffect(() => { + if (!isOpen) return; + const onKey = (e: KeyboardEvent) => { + if (e.key === 'Escape') onClose(); + }; + document.addEventListener('keydown', onKey); + return () => document.removeEventListener('keydown', onKey); + }, [isOpen, onClose]); + // Search the index (debounced). With an empty query we BROWSE the installed // list instead, so don't fire a search. useEffect(() => {