diff --git a/src/Input/Input.tsx b/src/Input/Input.tsx index 637d8b1a3..b6027ef7a 100644 --- a/src/Input/Input.tsx +++ b/src/Input/Input.tsx @@ -203,8 +203,8 @@ export const Input = ({ } // associate the input field with the help text - const infoId = id ? `${id}Description` : undefined; - if (id) { + const infoId = id && infoText ? `${id}Description` : undefined; + if (infoId) { extraAttributes['aria-describedby'] = infoId; } @@ -296,8 +296,11 @@ export const Input = ({ } const nativeInputValueSetter = Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, 'value')?.set; nativeInputValueSetter?.call(inputRef.current, `${newValue}`); + const ev1 = new Event('change', { bubbles: true }); const ev2 = new Event('input', { bubbles: true }); + inputRef.current?.dispatchEvent(ev1); inputRef.current?.dispatchEvent(ev2); + inputRef.current?.focus(); }; if (['currency', 'percentage', 'adaptive', 'number'].includes(type)) { @@ -328,10 +331,10 @@ export const Input = ({ ref={inputRef} /> - - diff --git a/stories/Components/Form/Input.stories.tsx b/stories/Components/Form/Input.stories.tsx index 2d88d2949..c3954ba78 100644 --- a/stories/Components/Form/Input.stories.tsx +++ b/stories/Components/Form/Input.stories.tsx @@ -16,8 +16,9 @@ export const EsempiDiCampiDiInput: Story = { return (
+ - +
);