From 5364655f1409d454e6b7ae761b4cd82ba4cb8827 Mon Sep 17 00:00:00 2001 From: simiondolha <34995943+simiondolha@users.noreply.github.com> Date: Thu, 15 Jan 2026 17:57:06 +0100 Subject: [PATCH] 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 Co-authored-by: Claude Opus 4.5 --- .../editor/plugins/ToolbarPlugin.tsx | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/packages/ui/components/editor/plugins/ToolbarPlugin.tsx b/packages/ui/components/editor/plugins/ToolbarPlugin.tsx index 2aeca63a7b..aea5cb558e 100644 --- a/packages/ui/components/editor/plugins/ToolbarPlugin.tsx +++ b/packages/ui/components/editor/plugins/ToolbarPlugin.tsx @@ -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 (