From 29c1ef11f0e8208477de8d3573eb8c36b9b1d152 Mon Sep 17 00:00:00 2001 From: Sergey Vinogradov Date: Wed, 10 Aug 2022 13:59:17 +0300 Subject: [PATCH] use composedPath instead of target --- packages/field-base/src/input-mixin.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/field-base/src/input-mixin.js b/packages/field-base/src/input-mixin.js index 54bdce6d60..17528fb633 100644 --- a/packages/field-base/src/input-mixin.js +++ b/packages/field-base/src/input-mixin.js @@ -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); } @@ -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; }