Skip to content

Commit

Permalink
use composedPath instead of target
Browse files Browse the repository at this point in the history
  • Loading branch information
vursen committed Aug 10, 2022
1 parent f94a70c commit 29c1ef1
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/field-base/src/input-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,11 @@ export const InputMixin = dedupingMixin(
* @private
*/
__onInput(event) {
this._hasInputValue = event.target.value.length > 0;
// In the case a custom web component is passed as `inputElement`,
// the actual native input element, on which the event occurred,
// can be inside shadow trees.
const target = event.composedPath()[0];
this._hasInputValue = target.value.length > 0;
this._onInput(event);
}

Expand All @@ -166,9 +170,13 @@ export const InputMixin = dedupingMixin(
* @protected
*/
_onInput(event) {
// In the case a custom web component is passed as `inputElement`,
// the actual native input element, on which the event occurred,
// can be inside shadow trees.
const target = event.composedPath()[0];
// Ignore fake input events e.g. used by clear button.
this.__userInput = event.isTrusted;
this.value = event.target.value;
this.value = target.value;
this.__userInput = false;
}

Expand Down

0 comments on commit 29c1ef1

Please sign in to comment.