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:
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 (
|
||||
|
||||
Reference in new issue
Block a user