diff --git a/src/components/textinput.js b/src/components/textinput.js index d6e8ad232..ae5b4ac03 100644 --- a/src/components/textinput.js +++ b/src/components/textinput.js @@ -7,6 +7,7 @@ const { actionVariableId: name, autoComplete, + autoFocus, disabled, error, label, @@ -68,6 +69,7 @@ const parsedLabel = useText(label); const labelText = parsedLabel; const debouncedOnChangeRef = useRef(null); + const inputRef = useRef(); const { current: labelControlRef } = useRef(generateUUID()); @@ -209,10 +211,16 @@ handleValidation(validity); }; + const focusHandler = () => + setTimeout(() => { + inputRef.current.focus(); + }, 0); + B.defineFunction('Clear', () => setCurrentValue('')); B.defineFunction('Enable', () => setIsDisabled(false)); B.defineFunction('Disable', () => setIsDisabled(true)); B.defineFunction('Reset', () => setCurrentValue(useText(value))); + B.defineFunction('Focus', () => focusHandler()); const handleClickShowPassword = () => { togglePassword(!showPassword); @@ -286,11 +294,13 @@ )}