Skip to content

Commit b3bb957

Browse files
fixed cursor jumping on rich text editor comp
1 parent d1d4876 commit b3bb957

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

client/packages/lowcoder/src/comps/comps/richTextEditorComp.tsx

+11-5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { ChangeEventHandlerControl } from "comps/controls/eventHandlerControl";
77
import { UICompBuilder, withDefault } from "comps/generators";
88
import { NameConfig, NameConfigHidden, withExposingConfigs } from "comps/generators/withExposing";
99
import { Section, sectionNames } from "lowcoder-design";
10-
import React, { Suspense, useEffect, useRef, useState } from "react";
10+
import React, { ChangeEvent, Suspense, useEffect, useRef, useState } from "react";
1111
import type ReactQuill from "react-quill";
1212
import { useDebounce } from "react-use";
1313
import styled, { css } from "styled-components";
@@ -19,7 +19,7 @@ import {
1919
readOnlyPropertyView,
2020
showDataLoadingIndicatorsPropertyView,
2121
} from "comps/utils/propertyUtils";
22-
import _ from "lodash";
22+
import _, { debounce } from "lodash";
2323
import { trans } from "i18n";
2424
import { default as Skeleton } from "antd/es/skeleton";
2525
import { styleControl } from "comps/controls/styleControl";
@@ -294,9 +294,15 @@ function RichTextEditor(props: IProps) {
294294
}
295295

296296
const RichTextEditorCompBase = new UICompBuilder(childrenMap, (props) => {
297-
const handleChange = (v: string) => {
298-
props.value.onChange(v);
299-
props.onEvent("change");
297+
const debouncedOnChangeRef = useRef(
298+
debounce((value: string) => {
299+
props.value.onChange(value);
300+
props.onEvent("change");
301+
}, 1000)
302+
);
303+
304+
const handleChange = (value: string) => {
305+
debouncedOnChangeRef.current?.(value);
300306
};
301307

302308
return (

0 commit comments

Comments
 (0)