UNPKG

@equinor/eds-utils

Version:

Utility functions and hooks for the Equinor Design System

19 lines (15 loc) 556 B
// Workaround // React ignores 'dispathEvent' on input/textarea, see https://github.com/facebook/react/issues/10135 const setReactInputValue = (input, value) => { const previousValue = input.value; input.value = value; const tracker = input._valueTracker; if (typeof tracker !== 'undefined') { tracker.setValue(previousValue); } //'change' instead of 'input', see https://github.com/facebook/react/issues/11488#issuecomment-381590324 input.dispatchEvent(new Event('change', { bubbles: true })); }; export { setReactInputValue };