@@ -11,7 +11,7 @@ import { stringExposingStateControl } from "comps/controls/codeStateControl";
1111import { LabelControl } from "comps/controls/labelControl" ;
1212import { InputLikeStyleType , LabelStyleType , heightCalculator , widthCalculator } from "comps/controls/styleControlConstants" ;
1313import { Section , sectionNames , ValueFromOption } from "lowcoder-design" ;
14- import { fromPairs } from "lodash" ;
14+ import { debounce , fromPairs } from "lodash" ;
1515import { css } from "styled-components" ;
1616import { EMAIL_PATTERN , URL_PATTERN } from "util/stringUtils" ;
1717import { MultiBaseComp , RecordConstructorToComp , RecordConstructorToView } from "lowcoder-core" ;
@@ -33,7 +33,7 @@ import {
3333 showDataLoadingIndicatorsPropertyView ,
3434} from "comps/utils/propertyUtils" ;
3535import { trans } from "i18n" ;
36- import { ChangeEvent , useEffect , useRef , useState } from "react" ;
36+ import { ChangeEvent , useEffect , useMemo , useRef , useState } from "react" ;
3737import { refMethods } from "comps/generators/withMethodExposing" ;
3838import { InputRef } from "antd/es/input" ;
3939import {
@@ -199,7 +199,6 @@ export const useTextInputProps = (props: RecordConstructorToView<typeof textInpu
199199 } ,
200200 } )
201201 ) ;
202- propsRef . current . onEvent ( "change" ) ;
203202 changeRef . current = false ;
204203 } , [ localInputValue ] ) ;
205204
@@ -216,19 +215,21 @@ export const useTextInputProps = (props: RecordConstructorToView<typeof textInpu
216215 ) ;
217216 } , [ props . customRule ] )
218217
219- const onChangeRef = useRef (
220- ( value : string ) => {
221- props . value . onChange ( value ) ;
222- }
218+ const debouncedOnChangeRef = useRef (
219+ debounce ( function ( value : string , valueCtx : any ) {
220+ propsRef . current . value . onChange ( value ) ;
221+ propsRef . current . onEvent ( "change" ) ;
222+ } , 1000 )
223223 ) ;
224+
224225
225226 const handleChange = ( e : ChangeEvent < HTMLInputElement > ) => {
226227 const value = e . target . value ;
227228 setLocalInputValue ( value ) ;
228229
229230 changeRef . current = true ;
230231 touchRef . current = true ;
231- onChangeRef . current ?.( value ) ;
232+ debouncedOnChangeRef . current ?.( value , propsRef . current . value ) ;
232233 } ;
233234
234235 // Cleanup refs on unmount
@@ -237,7 +238,7 @@ export const useTextInputProps = (props: RecordConstructorToView<typeof textInpu
237238 changeRef . current = false ;
238239 touchRef . current = false ;
239240 propsRef . current = null as any ;
240- onChangeRef . current = null as any ;
241+ debouncedOnChangeRef . current . cancel ( ) ;
241242 } ;
242243 } , [ ] ) ;
243244
0 commit comments