Support inputs in shadow DOM in disableOnInputFields mode #578
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I tried #557 with the new release, but it failed for us due to a special circumstance in our particular app: we embed it into a 3rd party pages, and for better encapsulation we wrap the whole app inside a shadow DOM.
This however comes with some side effects, also encountered in other places, especially due to the way events are handled across shadow boundaries: when the key event traverses the shadow root, its
event.target
is not anymore the (input) element the event originated from, but the shadow root (to "hide" the internals of the shadow DOM for the outer DOM). So now it's tagName is notINPUT
anymore, breaking the input/textarea detection.This PR tweaks the input detection just a little bit, to also support inputs inside a (open!) shadow DOM, by looking for the "real" event target using compoundPath.
Note that the change here is not only related to our particular use case of having the whole app wrapped in a shadow DOM. It should work also in the more general case, e.g. when rendering a custom element that contains an input. This scenario is replicated in the test I added here!
cc @st-h