Movatterモバイル変換


[0]ホーム

URL:


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

Commitd0d3169

Browse files
added debounce for text inputs to avoid glitch
1 parentf81eb8a commitd0d3169

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

‎client/packages/lowcoder/src/comps/comps/textInputComp/textInputConstants.tsx

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { stringExposingStateControl } from "comps/controls/codeStateControl";
1111
import{LabelControl}from"comps/controls/labelControl";
1212
import{InputLikeStyleType,LabelStyleType,heightCalculator,widthCalculator}from"comps/controls/styleControlConstants";
1313
import{Section,sectionNames,ValueFromOption}from"lowcoder-design";
14-
import{fromPairs}from"lodash";
14+
import{debounce,fromPairs}from"lodash";
1515
import{css}from"styled-components";
1616
import{EMAIL_PATTERN,URL_PATTERN}from"util/stringUtils";
1717
import{MultiBaseComp,RecordConstructorToComp,RecordConstructorToView}from"lowcoder-core";
@@ -33,7 +33,7 @@ import {
3333
showDataLoadingIndicatorsPropertyView,
3434
}from"comps/utils/propertyUtils";
3535
import{trans}from"i18n";
36-
import{ChangeEvent,useEffect,useRef,useState}from"react";
36+
import{ChangeEvent,useEffect,useMemo,useRef,useState}from"react";
3737
import{refMethods}from"comps/generators/withMethodExposing";
3838
import{InputRef}from"antd/es/input";
3939
import{
@@ -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-
constonChangeRef=useRef(
220-
(value:string)=>{
221-
props.value.onChange(value);
222-
}
218+
constdebouncedOnChangeRef=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
consthandleChange=(e:ChangeEvent<HTMLInputElement>)=>{
226227
constvalue=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=nullasany;
240-
onChangeRef.current=nullasany;
241+
debouncedOnChangeRef.current.cancel();
241242
};
242243
},[]);
243244

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp