From 97d3b0477230356b45df9220204afa5074fc7ecb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Hatcher?= Date: Sun, 29 Jun 2025 00:17:23 +0200 Subject: [PATCH] FIX: Prevent scroll when focus This are fixes to make the widget embedable --- webapp/IronCalc/src/components/Editor/Editor.tsx | 2 +- webapp/IronCalc/src/components/Workbook/Workbook.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/webapp/IronCalc/src/components/Editor/Editor.tsx b/webapp/IronCalc/src/components/Editor/Editor.tsx index 0b332b6..7be2eb3 100644 --- a/webapp/IronCalc/src/components/Editor/Editor.tsx +++ b/webapp/IronCalc/src/components/Editor/Editor.tsx @@ -114,7 +114,7 @@ const Editor = (options: EditorOptions) => { } } if (type === cell.focus) { - textareaRef.current?.focus(); + textareaRef.current?.focus({ preventScroll: true }); } }); diff --git a/webapp/IronCalc/src/components/Workbook/Workbook.tsx b/webapp/IronCalc/src/components/Workbook/Workbook.tsx index 1b66927..bdd2bed 100644 --- a/webapp/IronCalc/src/components/Workbook/Workbook.tsx +++ b/webapp/IronCalc/src/components/Workbook/Workbook.tsx @@ -48,7 +48,7 @@ const Workbook = (props: { model: Model; workbookState: WorkbookState }) => { ); const focusWorkbook = useCallback(() => { if (rootRef.current) { - rootRef.current.focus(); + rootRef.current.focus({ preventScroll: true }); // HACK: We need to select something inside the root for onCopy to work const selection = window.getSelection(); if (selection) {