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:
2026-04-26 15:45:18 -04:00
parent be5bdf15b7
commit ff10c2ffea
2 changed files with 5 additions and 0 deletions
@@ -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(() => {