Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Input control validation on focus out event #2036

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
15 changes: 15 additions & 0 deletions frontend/taipy-gui/src/components/Taipy/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,20 @@ const Input = (props: TaipyInputProps) => {
[changeDelay, dispatch, updateVarName, module, onChange, propagate]
);

const handleBlur = useCallback(
(e: React.FocusEvent<HTMLInputElement>) => {
const val = e.target.value;
if (changeDelay > 0 && delayCall.current > 0) {
clearTimeout(delayCall.current);
delayCall.current = -1;
dispatch(createSendUpdateAction(updateVarName, val, module, onChange, propagate));
Copy link
Member

@FredLL-Avaiga FredLL-Avaiga Oct 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should always be called
So put outside the if/else block
I think you're right this should only be called if there is delayed call on hold
Sorry about the noise

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But I still don't see any tests ;-)
Are you still working on this @kart2004 ?

} else if (changeDelay === -1) {
dispatch(createSendUpdateAction(updateVarName, val, module, onChange, propagate));
}
},
[dispatch, updateVarName, module, onChange, propagate, changeDelay]
);

const handleAction = useCallback(
(evt: KeyboardEvent<HTMLDivElement>) => {
if (evt.shiftKey && type === "number") {
Expand Down Expand Up @@ -340,6 +354,7 @@ const Input = (props: TaipyInputProps) => {
id={id}
slotProps={inputProps}
label={props.label}
onBlur={handleBlur}
onChange={handleInput}
disabled={!active}
onKeyDown={handleAction}
Expand Down