Skip to content

Commit 5ba4f59

Browse files
check input field validation on customRule's value change
1 parent 2100027 commit 5ba4f59

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ export const textInputProps = (props: RecordConstructorToView<typeof textInputCh
169169
export const useTextInputProps = (props: RecordConstructorToView<typeof textInputChildren>) => {
170170
const [validateState, setValidateState] = useState({});
171171
const changeRef = useRef(false)
172+
const touchRef = useRef(false);
172173

173174
const propsRef = useRef<RecordConstructorToView<typeof textInputChildren>>(props);
174175
propsRef.current = props;
@@ -195,9 +196,23 @@ export const useTextInputProps = (props: RecordConstructorToView<typeof textInpu
195196
changeRef.current = false;
196197
}, [inputValue]);
197198

199+
useEffect(() => {
200+
if (!touchRef.current) return;
201+
202+
setValidateState(
203+
textInputValidate({
204+
...propsRef.current,
205+
value: {
206+
value: props.value.value,
207+
},
208+
})
209+
);
210+
}, [props.customRule])
211+
198212
const handleChange = (e: ChangeEvent<HTMLInputElement>) => {
199213
props.value.onChange(e.target.value);
200214
changeRef.current = true;
215+
touchRef.current = true;
201216
};
202217

203218
return [

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy