fix(ui): prevent inline toolbar from hiding when interacting with submenus
- keep toolbar visible when focus moves to an element inside `[data-inline-toolbar]` - unpin toolbar on cleanup when submenu closes to avoid stale pinned state
This commit is contained in:
@@ -579,6 +579,10 @@ export default function BlockEditor({
|
||||
// passe sur l'input/bouton et la sélection peut paraître hors-bloc :
|
||||
// on garde la toolbar visible.
|
||||
if (toolbarPinnedRef.current) return;
|
||||
if (typeof document !== 'undefined') {
|
||||
const active = document.activeElement;
|
||||
if (active instanceof Element && active.closest('[data-inline-toolbar]')) return;
|
||||
}
|
||||
const sel = typeof window !== 'undefined' ? window.getSelection() : null;
|
||||
if (!sel || sel.rangeCount === 0 || sel.isCollapsed) {
|
||||
setToolbar(null);
|
||||
|
||||
@@ -47,6 +47,7 @@ export default function InlineToolbar({ rect, activeMarks, onToggleMark, onSetMa
|
||||
|
||||
useEffect(() => {
|
||||
onPinChange?.(openSubmenu !== null);
|
||||
return () => { onPinChange?.(false); };
|
||||
}, [openSubmenu, onPinChange]);
|
||||
|
||||
useLayoutEffect(() => {
|
||||
|
||||
Reference in New Issue
Block a user