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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user