diff --git a/lib/TextField/TextField.js b/lib/TextField/TextField.js index f687d502a..db27ae7d1 100644 --- a/lib/TextField/TextField.js +++ b/lib/TextField/TextField.js @@ -269,17 +269,20 @@ Use the "inputRef" prop instead to obtain a ref to the input.`); clearField() { const { onClearField } = this.props; - this.setState({ value: '' }, () => { - // Fire callback - if (typeof onClearField === 'function') { - onClearField(); - } + // Fire callback + if (typeof onClearField === 'function') { + onClearField(); + } - // Set focus on input again - if (this.input.current) { - this.input.current.focus(); - } - }); + // Clear value on input natively, dispatch an event to be picked up by handleChange, and focus on input again + if (this.input.current) { + const nativeInputValueSetter = Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, 'value').set; + nativeInputValueSetter.call(this.input.current, ''); + + const ev = new Event('change', { bubbles: true }); + this.input.current.dispatchEvent(ev); + this.input.current.focus(); + } } handleChange(event) {