diff --git a/accessibility/keyboardui.js b/accessibility/keyboardui.js index 1b4eea6f..5a3f3ba1 100644 --- a/accessibility/keyboardui.js +++ b/accessibility/keyboardui.js @@ -210,6 +210,9 @@ const AreaManager = { /* Overlay for gizmo buttons */ const GizmoMenuManager = { overlay: null, + // Other menus (e.g. the add-shape dropdown) that should close themselves + // when the gizmo overlay opens, so they don't sit on top of the gizmos. + _closeHooks: [], buttons: [ { id: 'showShapesButton', label: '1' }, { id: 'colorPickerButton', label: '2' }, @@ -241,9 +244,20 @@ const GizmoMenuManager = { return !this.overlay.classList.contains('hidden'); }, + registerCloseHook(fn) { + this._closeHooks.push(fn); + }, + toggle(show) { if (!this.overlay) return; if (show) { + this._closeHooks.forEach((fn) => { + try { + fn(); + } catch (e) { + console.error('GizmoMenuManager close hook failed:', e); + } + }); this.renderBadges(); if (this._watchFocus) { diff --git a/ui/addmenu.js b/ui/addmenu.js index 86ad3126..ff0ad3d9 100644 --- a/ui/addmenu.js +++ b/ui/addmenu.js @@ -925,6 +925,16 @@ function cancelPlacement() { cleanupPlacementMode(); } +// Close the add-shape dropdown when the gizmo overlay opens (e.g. Ctrl+G), +// so it doesn't sit on top of the gizmo buttons it's meant to reveal. +GizmoMenuManager.registerCloseHook(() => { + const dropdown = document.getElementById("shapes-dropdown"); + if (!dropdown || dropdown.style.display === "none") return; + dropdown.style.display = "none"; + removeKeyboardNavigation(); + cancelPlacement(); +}); + // --- Keyboard Navigation --- let currentFocusedElement = null;