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 :
|
// passe sur l'input/bouton et la sélection peut paraître hors-bloc :
|
||||||
// on garde la toolbar visible.
|
// on garde la toolbar visible.
|
||||||
if (toolbarPinnedRef.current) return;
|
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;
|
const sel = typeof window !== 'undefined' ? window.getSelection() : null;
|
||||||
if (!sel || sel.rangeCount === 0 || sel.isCollapsed) {
|
if (!sel || sel.rangeCount === 0 || sel.isCollapsed) {
|
||||||
setToolbar(null);
|
setToolbar(null);
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ export default function InlineToolbar({ rect, activeMarks, onToggleMark, onSetMa
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
onPinChange?.(openSubmenu !== null);
|
onPinChange?.(openSubmenu !== null);
|
||||||
|
return () => { onPinChange?.(false); };
|
||||||
}, [openSubmenu, onPinChange]);
|
}, [openSubmenu, onPinChange]);
|
||||||
|
|
||||||
useLayoutEffect(() => {
|
useLayoutEffect(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user