From 9e0558bb1af61ee8f7b55148fbde112cb8e0dec6 Mon Sep 17 00:00:00 2001 From: Narek Malkhasyan Date: Tue, 29 Apr 2025 22:51:11 +0400 Subject: [PATCH 1/3] Don't scroll page when TTDDialog is opened --- package.json | 4 ++-- packages/common/package.json | 4 ++-- packages/element/package.json | 4 ++-- packages/excalidraw/components/App.tsx | 5 +++-- packages/excalidraw/components/TTDDialog/TTDDialogInput.tsx | 2 +- packages/excalidraw/package.json | 4 ++-- packages/math/package.json | 4 ++-- packages/utils/package.json | 4 ++-- 8 files changed, 16 insertions(+), 15 deletions(-) diff --git a/package.json b/package.json index 6f57f7e7c..07ebdaf5c 100644 --- a/package.json +++ b/package.json @@ -78,8 +78,8 @@ "autorelease": "node scripts/autorelease.js", "prerelease:excalidraw": "node scripts/prerelease.js", "release:excalidraw": "node scripts/release.js", - "rm:build": "rm -rf excalidraw-app/{build,dist,dev-dist} && rm -rf packages/*/{dist,build} && rm -rf examples/*/{build,dist}", - "rm:node_modules": "rm -rf node_modules && rm -rf excalidraw-app/node_modules && rm -rf packages/*/node_modules", + "rm:build": "rimraf excalidraw-app/{build,dist,dev-dist} && rimraf packages/*/{dist,build} && rimraf examples/*/{build,dist}", + "rm:node_modules": "rimraf node_modules && rimraf excalidraw-app/node_modules && rimraf packages/*/node_modules", "clean-install": "yarn rm:node_modules && yarn install" }, "resolutions": { diff --git a/packages/common/package.json b/packages/common/package.json index 3e5f6413a..32cffc717 100644 --- a/packages/common/package.json +++ b/packages/common/package.json @@ -50,7 +50,7 @@ "bugs": "https://github.com/excalidraw/excalidraw/issues", "repository": "https://github.com/excalidraw/excalidraw", "scripts": { - "gen:types": "rm -rf types && tsc", - "build:esm": "rm -rf dist && node ../../scripts/buildBase.js && yarn gen:types" + "gen:types": "rimraf types && tsc", + "build:esm": "rimraf dist && node ../../scripts/buildBase.js && yarn gen:types" } } diff --git a/packages/element/package.json b/packages/element/package.json index ae810e374..1eec60742 100644 --- a/packages/element/package.json +++ b/packages/element/package.json @@ -50,7 +50,7 @@ "bugs": "https://github.com/excalidraw/excalidraw/issues", "repository": "https://github.com/excalidraw/excalidraw", "scripts": { - "gen:types": "rm -rf types && tsc", - "build:esm": "rm -rf dist && node ../../scripts/buildBase.js && yarn gen:types" + "gen:types": "rimraf types && tsc", + "build:esm": "rimraf dist && node ../../scripts/buildBase.js && yarn gen:types" } } diff --git a/packages/excalidraw/components/App.tsx b/packages/excalidraw/components/App.tsx index 0381a2e39..26a2d30ee 100644 --- a/packages/excalidraw/components/App.tsx +++ b/packages/excalidraw/components/App.tsx @@ -2960,7 +2960,8 @@ class App extends React.Component { this.scheduleImageRefresh(); }; - private onScroll = debounce(() => { + private onScroll = () => { + debugger; const { offsetTop, offsetLeft } = this.getCanvasOffsets(); this.setState((state) => { if (state.offsetLeft === offsetLeft && state.offsetTop === offsetTop) { @@ -2968,7 +2969,7 @@ class App extends React.Component { } return { offsetTop, offsetLeft }; }); - }, SCROLL_TIMEOUT); + }; // Copy/paste diff --git a/packages/excalidraw/components/TTDDialog/TTDDialogInput.tsx b/packages/excalidraw/components/TTDDialog/TTDDialogInput.tsx index 9bd80b681..df8dd61b0 100644 --- a/packages/excalidraw/components/TTDDialog/TTDDialogInput.tsx +++ b/packages/excalidraw/components/TTDDialog/TTDDialogInput.tsx @@ -28,6 +28,7 @@ export const TTDDialogInput = ({ } const textarea = ref.current; if (textarea) { + textarea.focus(); const handleKeyDown = (event: KeyboardEvent) => { if (event[KEYS.CTRL_OR_CMD] && event.key === KEYS.ENTER) { event.preventDefault(); @@ -47,7 +48,6 @@ export const TTDDialogInput = ({ onChange={onChange} value={input} placeholder={placeholder} - autoFocus ref={ref} /> ); diff --git a/packages/excalidraw/package.json b/packages/excalidraw/package.json index 27fae8455..7ebaed742 100644 --- a/packages/excalidraw/package.json +++ b/packages/excalidraw/package.json @@ -129,7 +129,7 @@ "bugs": "https://github.com/excalidraw/excalidraw/issues", "homepage": "https://github.com/excalidraw/excalidraw/tree/master/packages/excalidraw", "scripts": { - "gen:types": "rm -rf types && tsc", - "build:esm": "rm -rf dist && node ../../scripts/buildPackage.js && yarn gen:types" + "gen:types": "rimraf types && tsc", + "build:esm": "rimraf dist && node ../../scripts/buildPackage.js && yarn gen:types" } } diff --git a/packages/math/package.json b/packages/math/package.json index f8b411891..e9f5fd8da 100644 --- a/packages/math/package.json +++ b/packages/math/package.json @@ -54,7 +54,7 @@ "bugs": "https://github.com/excalidraw/excalidraw/issues", "repository": "https://github.com/excalidraw/excalidraw", "scripts": { - "gen:types": "rm -rf types && tsc", - "build:esm": "rm -rf dist && node ../../scripts/buildBase.js && yarn gen:types" + "gen:types": "rimraf types && tsc", + "build:esm": "rimraf dist && node ../../scripts/buildBase.js && yarn gen:types" } } diff --git a/packages/utils/package.json b/packages/utils/package.json index ca3eee23e..2dc54c59c 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -69,7 +69,7 @@ "bugs": "https://github.com/excalidraw/excalidraw/issues", "repository": "https://github.com/excalidraw/excalidraw", "scripts": { - "gen:types": "rm -rf types && tsc", - "build:esm": "rm -rf dist && node ../../scripts/buildUtils.js && yarn gen:types" + "gen:types": "rimraf types && tsc", + "build:esm": "rimraf dist && node ../../scripts/buildUtils.js && yarn gen:types" } } From c9ddf6075b6a40aa2fbd94d2cc08af006b22e28b Mon Sep 17 00:00:00 2001 From: Narek Malkhasyan Date: Wed, 30 Apr 2025 09:27:56 +0400 Subject: [PATCH 2/3] Revert "Don't scroll page when TTDDialog is opened" This reverts commit 9e0558bb1af61ee8f7b55148fbde112cb8e0dec6. --- package.json | 4 ++-- packages/common/package.json | 4 ++-- packages/element/package.json | 4 ++-- packages/excalidraw/components/App.tsx | 5 ++--- packages/excalidraw/components/TTDDialog/TTDDialogInput.tsx | 2 +- packages/excalidraw/package.json | 4 ++-- packages/math/package.json | 4 ++-- packages/utils/package.json | 4 ++-- 8 files changed, 15 insertions(+), 16 deletions(-) diff --git a/package.json b/package.json index 07ebdaf5c..6f57f7e7c 100644 --- a/package.json +++ b/package.json @@ -78,8 +78,8 @@ "autorelease": "node scripts/autorelease.js", "prerelease:excalidraw": "node scripts/prerelease.js", "release:excalidraw": "node scripts/release.js", - "rm:build": "rimraf excalidraw-app/{build,dist,dev-dist} && rimraf packages/*/{dist,build} && rimraf examples/*/{build,dist}", - "rm:node_modules": "rimraf node_modules && rimraf excalidraw-app/node_modules && rimraf packages/*/node_modules", + "rm:build": "rm -rf excalidraw-app/{build,dist,dev-dist} && rm -rf packages/*/{dist,build} && rm -rf examples/*/{build,dist}", + "rm:node_modules": "rm -rf node_modules && rm -rf excalidraw-app/node_modules && rm -rf packages/*/node_modules", "clean-install": "yarn rm:node_modules && yarn install" }, "resolutions": { diff --git a/packages/common/package.json b/packages/common/package.json index 32cffc717..3e5f6413a 100644 --- a/packages/common/package.json +++ b/packages/common/package.json @@ -50,7 +50,7 @@ "bugs": "https://github.com/excalidraw/excalidraw/issues", "repository": "https://github.com/excalidraw/excalidraw", "scripts": { - "gen:types": "rimraf types && tsc", - "build:esm": "rimraf dist && node ../../scripts/buildBase.js && yarn gen:types" + "gen:types": "rm -rf types && tsc", + "build:esm": "rm -rf dist && node ../../scripts/buildBase.js && yarn gen:types" } } diff --git a/packages/element/package.json b/packages/element/package.json index 1eec60742..ae810e374 100644 --- a/packages/element/package.json +++ b/packages/element/package.json @@ -50,7 +50,7 @@ "bugs": "https://github.com/excalidraw/excalidraw/issues", "repository": "https://github.com/excalidraw/excalidraw", "scripts": { - "gen:types": "rimraf types && tsc", - "build:esm": "rimraf dist && node ../../scripts/buildBase.js && yarn gen:types" + "gen:types": "rm -rf types && tsc", + "build:esm": "rm -rf dist && node ../../scripts/buildBase.js && yarn gen:types" } } diff --git a/packages/excalidraw/components/App.tsx b/packages/excalidraw/components/App.tsx index 26a2d30ee..0381a2e39 100644 --- a/packages/excalidraw/components/App.tsx +++ b/packages/excalidraw/components/App.tsx @@ -2960,8 +2960,7 @@ class App extends React.Component { this.scheduleImageRefresh(); }; - private onScroll = () => { - debugger; + private onScroll = debounce(() => { const { offsetTop, offsetLeft } = this.getCanvasOffsets(); this.setState((state) => { if (state.offsetLeft === offsetLeft && state.offsetTop === offsetTop) { @@ -2969,7 +2968,7 @@ class App extends React.Component { } return { offsetTop, offsetLeft }; }); - }; + }, SCROLL_TIMEOUT); // Copy/paste diff --git a/packages/excalidraw/components/TTDDialog/TTDDialogInput.tsx b/packages/excalidraw/components/TTDDialog/TTDDialogInput.tsx index df8dd61b0..9bd80b681 100644 --- a/packages/excalidraw/components/TTDDialog/TTDDialogInput.tsx +++ b/packages/excalidraw/components/TTDDialog/TTDDialogInput.tsx @@ -28,7 +28,6 @@ export const TTDDialogInput = ({ } const textarea = ref.current; if (textarea) { - textarea.focus(); const handleKeyDown = (event: KeyboardEvent) => { if (event[KEYS.CTRL_OR_CMD] && event.key === KEYS.ENTER) { event.preventDefault(); @@ -48,6 +47,7 @@ export const TTDDialogInput = ({ onChange={onChange} value={input} placeholder={placeholder} + autoFocus ref={ref} /> ); diff --git a/packages/excalidraw/package.json b/packages/excalidraw/package.json index 7ebaed742..27fae8455 100644 --- a/packages/excalidraw/package.json +++ b/packages/excalidraw/package.json @@ -129,7 +129,7 @@ "bugs": "https://github.com/excalidraw/excalidraw/issues", "homepage": "https://github.com/excalidraw/excalidraw/tree/master/packages/excalidraw", "scripts": { - "gen:types": "rimraf types && tsc", - "build:esm": "rimraf dist && node ../../scripts/buildPackage.js && yarn gen:types" + "gen:types": "rm -rf types && tsc", + "build:esm": "rm -rf dist && node ../../scripts/buildPackage.js && yarn gen:types" } } diff --git a/packages/math/package.json b/packages/math/package.json index e9f5fd8da..f8b411891 100644 --- a/packages/math/package.json +++ b/packages/math/package.json @@ -54,7 +54,7 @@ "bugs": "https://github.com/excalidraw/excalidraw/issues", "repository": "https://github.com/excalidraw/excalidraw", "scripts": { - "gen:types": "rimraf types && tsc", - "build:esm": "rimraf dist && node ../../scripts/buildBase.js && yarn gen:types" + "gen:types": "rm -rf types && tsc", + "build:esm": "rm -rf dist && node ../../scripts/buildBase.js && yarn gen:types" } } diff --git a/packages/utils/package.json b/packages/utils/package.json index 2dc54c59c..ca3eee23e 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -69,7 +69,7 @@ "bugs": "https://github.com/excalidraw/excalidraw/issues", "repository": "https://github.com/excalidraw/excalidraw", "scripts": { - "gen:types": "rimraf types && tsc", - "build:esm": "rimraf dist && node ../../scripts/buildUtils.js && yarn gen:types" + "gen:types": "rm -rf types && tsc", + "build:esm": "rm -rf dist && node ../../scripts/buildUtils.js && yarn gen:types" } } From 5a88b95df50714028dd0d631eed0fcd673057c85 Mon Sep 17 00:00:00 2001 From: Narek Malkhasyan Date: Wed, 30 Apr 2025 09:31:09 +0400 Subject: [PATCH 3/3] Don't scroll page when TTDDialog is opened --- packages/excalidraw/components/TTDDialog/TTDDialogInput.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/excalidraw/components/TTDDialog/TTDDialogInput.tsx b/packages/excalidraw/components/TTDDialog/TTDDialogInput.tsx index 9bd80b681..24427d52d 100644 --- a/packages/excalidraw/components/TTDDialog/TTDDialogInput.tsx +++ b/packages/excalidraw/components/TTDDialog/TTDDialogInput.tsx @@ -34,6 +34,7 @@ export const TTDDialogInput = ({ callbackRef.current?.(); } }; + textarea.focus(); textarea.addEventListener(EVENT.KEYDOWN, handleKeyDown); return () => { textarea.removeEventListener(EVENT.KEYDOWN, handleKeyDown); @@ -47,7 +48,6 @@ export const TTDDialogInput = ({ onChange={onChange} value={input} placeholder={placeholder} - autoFocus ref={ref} /> );