Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 9ec5282

Browse files
fix cursor jump issue while typing
1 parent 11f1022 commit 9ec5282

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

‎client/packages/lowcoder/src/base/codeEditor/codeEditor.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { CodeEditorPanel } from "../../pages/editor/codeEditorPanel";
1414
import type { CodeEditorProps, StyleName } from "./codeEditorTypes";
1515
import { useClickCompNameEffect } from "./clickCompName";
1616
import { Layers } from "../../constants/Layers";
17+
import { debounce } from "lodash";
1718

1819
type StyleConfig = {
1920
minHeight: string;
@@ -219,12 +220,12 @@ function useCodeMirror(
219220
const showLineNum = props.showLineNum ?? getStyle(props.styleName).showLineNum;
220221

221222
const handleChange = useCallback(
222-
(state: EditorState) => {
223+
debounce((state: EditorState) => {
223224
window.clearTimeout(isTypingRef.current);
224225
isTypingRef.current = window.setTimeout(() => (isTypingRef.current = 0), 100);
225226
onChange?.(state);
226-
},
227-
[onChange]
227+
},100)
228+
,[onChange]
228229
);
229230

230231
const { extensions, reconfigure, isFocus } = useExtensions({

‎client/packages/lowcoder/src/comps/controls/codeControl.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,18 +100,18 @@ export function codeControl<
100100
this._exposingNode = withFunction(this._node, (x) => x.value);
101101

102102
// make sure handleChange's reference only changes when the instance changes, avoid CodeEditor frequent reconfigure
103-
this.handleChange = debounce((state: EditorState) => {
103+
this.handleChange = (state: EditorState) => {
104104
this.dispatchChangeValueAction(state.doc.toString());
105-
},50);
105+
};
106106
}
107107

108108
override changeDispatch(dispatch: DispatchType) {
109109
// need to re-bind handleChange when dispatch changes, otherwise old instance's dispatch is still in use
110110
const comp = setFieldsNoTypeCheck(this, {
111111
dispatch,
112-
handleChange: debounce((state: EditorState) => {
112+
handleChange: (state: EditorState) => {
113113
comp.dispatchChangeValueAction(state.doc.toString());
114-
},50),
114+
},
115115
});
116116
return comp;
117117
}

‎client/packages/lowcoder/src/comps/generators/uiCompBuilder.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,11 @@ export function ExtendedPropertyView<
7575
const [compVersions, setCompVersions] = useState(['latest']);
7676
const [compName, setCompName] = useState('');
7777
const editorState = useContext(EditorContext);
78-
const selectedComp = values(editorState.selectedComps())[0];
79-
const compType = selectedComp.children.compType.getView() as UICompType;
78+
const selectedComp = values(editorState?.selectedComps())[0];
79+
const compType = selectedComp?.children?.compType?.getView() as UICompType;
8080

8181
useEffect(() => {
82-
setCompName(uiCompRegistry[compType].compName || '');
82+
setCompName(uiCompRegistry[compType]?.compName || '');
8383
}, [compType]);
8484

8585
useEffect(() => {

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /