fix(VOverlay): close on scrim click in Shadow DOM without activator #20291
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.
Description
Overlay container created outside Shadow DOM
VOverlays inside Shadow DOM get the root node from activatorEl to add the overlay container. However, when there is no activator, like when using VDialogs with v-model, the root node can't be found and the
.v-overlay-container
is created outsidethe Shadow DOM.
Fixed this by trying to get the root node from $el if it could not be found from activatorEl.
VDialog not closing on Scrim click
VOverlays inside Shadow DOM were not closing when clicking outside, in the scrim. The problem was in the click-outside directive, because the click event inside the Shadow DOM changes its target to the root once setTimeout triggers, and then the event is discarded because the target is no longer the Scrim.
Fixed this by retaining the original target of the event in a custom property in MouseEvent object, called
shadowTarget
, so VOverlay can use it after trying with the normal event target.Markup:
In this playground there are different menus and modals, both in the shadow DOM and in the document: