fix(BlockEditor): close slash menu when clicking outside or on different block

- add `handleFocus` in Block to reopen slash menu on focus if content starts with `/`
- add `outerRef` on editor root div to detect outside clicks
- add `useEffect` with document `mousedown` listener to close slash menu when clicking outside the editor or on a different block
- add `data-slash-menu` attribute on SlashMenu to exclude it from the close trigger
This commit is contained in:
2026-04-25 20:05:32 -04:00
parent 20f31269e4
commit c87f74a18e
3 changed files with 36 additions and 3 deletions
@@ -120,6 +120,7 @@ export default function SlashMenu({
return (
<div
ref={listRef}
data-slash-menu
className="fixed z-50 overflow-y-auto rounded-lg border border-neutral-200 dark:border-neutral-700 bg-white dark:bg-neutral-900 shadow-md py-1"
style={{ top, left, width: MENU_WIDTH, maxHeight }}
onMouseDown={(e) => e.preventDefault()} // ne pas voler le focus