From 84fe5ece1a313f853a396ac6319da0160f5bf81f Mon Sep 17 00:00:00 2001 From: pojol Date: Mon, 3 Jul 2023 16:13:00 +0800 Subject: [PATCH] fix : Fix the issue of losing focus when editing code in the code editor window --- editor/src/pages/config.tsx | 4 ++-- editor/src/pages/edit/node/action.tsx | 5 +++-- editor/src/pages/prefab.tsx | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/editor/src/pages/config.tsx b/editor/src/pages/config.tsx index e07f9f9..868e266 100644 --- a/editor/src/pages/config.tsx +++ b/editor/src/pages/config.tsx @@ -156,9 +156,9 @@ export default function Config() { ); }; - const onChange = React.useCallback((value:any, viewUpdate:any) => { + const onChange = (value:any, viewUpdate:any) => { setState((state) => ({ ...state, globalPrefab: value })); - }, []); + } const clickTheme = (e: any) => { setState((state) => ({ ...state, theme: e })); diff --git a/editor/src/pages/edit/node/action.tsx b/editor/src/pages/edit/node/action.tsx index 5f6ed54..a921e49 100644 --- a/editor/src/pages/edit/node/action.tsx +++ b/editor/src/pages/edit/node/action.tsx @@ -22,6 +22,7 @@ import ThemeType from '@/constant/constant'; const { Search } = Input; export default function ActionTab() { + const [state, setState] = useState({ nod: getDefaultNodeNotifyInfo(), node_ty: "", @@ -116,12 +117,12 @@ export default function ActionTab() { dispatch(nodeRedraw()) }; - const onChange = React.useCallback((value:any, viewUpdate:any) => { + const onChange = (value:any, viewUpdate:any) => { setState({ ...state, code: value, }); - }, []); + } const handleAliasChange = (event: any) => { setState({ diff --git a/editor/src/pages/prefab.tsx b/editor/src/pages/prefab.tsx index 7307fa0..b9ad13e 100644 --- a/editor/src/pages/prefab.tsx +++ b/editor/src/pages/prefab.tsx @@ -155,9 +155,9 @@ const Prefab = (props: PrefabProps) => { }); } - const onChange = React.useCallback((value:any, viewUpdate:any) => { + const onChange = (value:any, viewUpdate:any) => { setCode(value) - }, []); + } const uploadPrefab = (name: string, code: string) => {