fix: Another spot rules of hooks were broken (#10836)

This commit is contained in:
Tom Moor authored and GitHub committed 2025-12-08 19:27:40 +00:00
1 parent c3ad5bb7f6
commit e30c35acdb
1 file changed
+20 -20
+20 -20
View File
@@ -136,6 +136,26 @@ export function SelectionToolbar(props: Props) {
};
}, [isActive, readOnly, view]);
useEventListener(
"keydown",
(ev: KeyboardEvent) => {
if (
isModKey(ev) &&
ev.key.toLowerCase() === "k" &&
!view.state.selection.empty
) {
ev.stopPropagation();
if (activeToolbar === Toolbar.Link) {
setActiveToolbar(Toolbar.Menu);
} else if (activeToolbar === Toolbar.Menu) {
setActiveToolbar(Toolbar.Link);
}
}
},
view.dom,
{ capture: true }
);
if (isDragging) {
return null;
}
@@ -234,26 +254,6 @@ export function SelectionToolbar(props: Props) {
setActiveToolbar(null);
};
useEventListener(
"keydown",
(ev: KeyboardEvent) => {
if (
isModKey(ev) &&
ev.key.toLowerCase() === "k" &&
!view.state.selection.empty
) {
ev.stopPropagation();
if (activeToolbar === Toolbar.Link) {
setActiveToolbar(Toolbar.Menu);
} else if (activeToolbar === Toolbar.Menu) {
setActiveToolbar(Toolbar.Link);
}
}
},
view.dom,
{ capture: true }
);
if (!activeToolbar || !items.length) {
return null;
}