fix(ui): prevent page scroll when link button clicked in toolbar (#26662)

Adds e.preventDefault() to link button click handler to prevent
unexpected page scrolling behavior.

Fixes #26435

Co-authored-by: simiondolha <simiondolha@users.noreply.github.com>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
authored and GitHub committed 2026-01-15 16:57:06 +00:00
1 parent 22201cbc75
commit 5364655f14
1 file changed
+11 -7
@@ -441,13 +441,17 @@ export default function ToolbarPlugin(props: TextEditorProps) {
);
}, [editor, updateToolbar]);
const insertLink = useCallback(() => {
if (!isLink) {
editor.dispatchCommand(TOGGLE_LINK_COMMAND, "https://");
} else {
editor.dispatchCommand(TOGGLE_LINK_COMMAND, null);
}
}, [editor, isLink]);
const insertLink = useCallback(
(e: React.MouseEvent) => {
e.preventDefault();
if (!isLink) {
editor.dispatchCommand(TOGGLE_LINK_COMMAND, "https://");
} else {
editor.dispatchCommand(TOGGLE_LINK_COMMAND, null);
}
},
[editor, isLink]
);
if (!props.editable) return null;
return (