Repository: Avaiga/taipy
File: frontend/taipy-gui/src/components/Taipy/Input.tsx (TypeScript)

Code before:
            if (changeDelay === -1) {
                return;
            }
            if (changeDelay === 0) {
                delayCall.current = window.setTimeout(() => {
                    dispatch(createSendUpdateAction(updateVarName, value, module, onChange, propagate));
                }, 0.1);
                return;
            }
            if (delayCall.current > 0) {
                clearTimeout(delayCall.current);
            }
            delayCall.current = window.setTimeout(() => {
                delayCall.current = -1;
                dispatch(createSendUpdateAction(updateVarName, value, module, onChange, propagate));
            }, changeDelay);
        },
        [changeDelay, dispatch, updateVarName, module, onChange, propagate]
    );

    const handleInput = useCallback(
        (e: React.ChangeEvent<HTMLInputElement>) => {
            const val = e.target.value;
            setValue(val);
            if (changeDelay === 0) {
                delayCall.current = window.setTimeout(() => {
                    dispatch(createSendUpdateAction(updateVarName, val, module, onChange, propagate));
                }, 0.1);
                return;
            }
            if (changeDelay > 0) {
                if (delayCall.current > 0) {
                    clearTimeout(delayCall.current);
                }
                delayCall.current = window.setTimeout(() => {
                    delayCall.current = -1;
                    dispatch(createSendUpdateAction(updateVarName, val, module, onChange, propagate));
                }, changeDelay);
            }
        },
        [updateVarName, dispatch, propagate, onChange, changeDelay, module]
    );

    const handleAction = useCallback(
        (evt: KeyboardEvent<HTMLDivElement>) => {
            if (evt.shiftKey && type === "number") {
                if (evt.key === "ArrowUp") {
                    let val =
                        Number(evt.currentTarget.querySelector("input")?.value || 0) +
                        (step || 1) * (stepMultiplier || 10);
                    if (max !== undefined && val > max) {

Review comment (suggestion):
idem
and I think you don't need the setTimeout if handleInput is only called by user interaction (ie not in a setState)

Code after:
            if (changeDelay === -1) {
                return;
            }
            if (changeDelay === 0) {
                // Workaround using microtask to ensure the value is updated before the next action to avoid the bad setState behavior
                Promise.resolve().then(() => {
                    dispatch(createSendUpdateAction(updateVarName, value, module, onChange, propagate));
                });
                return;
            }
            if (delayCall.current > 0) {
                clearTimeout(delayCall.current);
            }
            delayCall.current = window.setTimeout(() => {
                delayCall.current = -1;
                dispatch(createSendUpdateAction(updateVarName, value, module, onChange, propagate));
            }, changeDelay);
        },
        [changeDelay, dispatch, updateVarName, module, onChange, propagate]
    );

    const handleInput = useCallback(
        (e: React.ChangeEvent<HTMLInputElement>) => {
            const val = e.target.value;
            setValue(val);
            dispatch(createSendUpdateAction(updateVarName, val, module, onChange, propagate));
        },
        [updateVarName, dispatch, propagate, onChange, module]
    );

    const handleAction = useCallback(
        (evt: KeyboardEvent<HTMLDivElement>) => {
            if (evt.shiftKey && type === "number") {
                if (evt.key === "ArrowUp") {
                    let val =
                        Number(evt.currentTarget.querySelector("input")?.value || 0) +
                        (step || 1) * (stepMultiplier || 10);
                    if (max !== undefined && val > max) {
                        val = max;
                    }
                    setValue(val.toString());
                    updateValueWithDelay(val);
                    evt.preventDefault();
                } else if (evt.key === "ArrowDown") {
                    let val =
                        Number(evt.currentTarget.querySelector("input")?.value || 0) -
                        (step || 1) * (stepMultiplier || 10);
                    if (min !== undefined && val < min) {
                        val = min;
                    }
                    setValue(val.toString());