Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Support Shadow DOM in VOverlay-enabled components such as VMenu and VSelect #17074

Closed
Maxim-Mazurok opened this issue Apr 4, 2023 · 2 comments
Labels
duplicate The issue has already been reported

Comments

@Maxim-Mazurok
Copy link
Contributor

Maxim-Mazurok commented Apr 4, 2023

Problem to solve

Currently VMenu, VSelect and others by default will be attached to the real DOM and will use styles from the root document instead of using ones from the Shadow DOM. This doesn't work for us because we're migrating from Bootstrap to Vuetify and we can't mix two CSS frameworks.
Possible solution we've explored was using contained or attach=this, however this creates a problem with z-index. For example, when we had a <VSelect contained=true/> - the contents of dropdown were appearing to be behind the <VCheckbox/> that followed select (kinda demo).

Proposed solution

I've created a patch for Veutify v3.1.2 using npx patch-package that will attempt to put VOverlay into the Shadow DOM root node. If this seems like a reasonable solution - I'll be happy to open a PR.

diff --git a/node_modules/vuetify/lib/components/VOverlay/VOverlay.mjs b/node_modules/vuetify/lib/components/VOverlay/VOverlay.mjs
index defc418..fc2df3a 100644
--- a/node_modules/vuetify/lib/components/VOverlay/VOverlay.mjs
+++ b/node_modules/vuetify/lib/components/VOverlay/VOverlay.mjs
@@ -101,7 +102,7 @@ export const VOverlay = genericComponent()({
     });
     const {
       teleportTarget
-    } = useTeleport(computed(() => props.attach || props.contained));
+    } = useTeleport(computed(() => props.attach || props.contained || theRootest.value?.getRootNode() || false));
     const {
       themeClasses
     } = provideTheme(props);
@@ -142,6 +143,7 @@ export const VOverlay = genericComponent()({
       if (v) isActive.value = false;
     });
     const root = ref();
+    const theRootest = ref();
     const contentEl = ref();
     const {
       contentStyles,
@@ -219,7 +221,9 @@ export const VOverlay = genericComponent()({
     }
     useRender(() => {
       var _slots$activator, _slots$default;
-      return _createVNode(_Fragment, null, [(_slots$activator = slots.activator) == null ? void 0 : _slots$activator.call(slots, {
+      return _createVNode(_Fragment, {
+        "ref": theRootest
+      }, [(_slots$activator = slots.activator) == null ? void 0 : _slots$activator.call(slots, {
         isActive: isActive.value,
         props: mergeProps({
           ref: activatorRef

In 3.1.16 change getRootNode() to getRootNode()?.body

@github-actions github-actions bot added the S: stale This issue is untriaged and hasn't seen any activity in at least six months. label Feb 21, 2024
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Mar 9, 2024
@Maxim-Mazurok
Copy link
Contributor Author

@KaelWD or @johnleider do you mind reopening this one, please? I didn't have a chance to un-stale it.

@johnleider johnleider reopened this Mar 18, 2024
@github-actions github-actions bot removed the S: stale This issue is untriaged and hasn't seen any activity in at least six months. label Mar 19, 2024
@KaelWD
Copy link
Member

KaelWD commented Aug 16, 2024

Duplicate of #19943

@KaelWD KaelWD marked this as a duplicate of #19943 Aug 16, 2024
@KaelWD KaelWD closed this as not planned Won't fix, can't repro, duplicate, stale Aug 16, 2024
@KaelWD KaelWD removed their assignment Aug 16, 2024
@github-actions github-actions bot added duplicate The issue has already been reported and removed S: triage labels Aug 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate The issue has already been reported
Projects
None yet
Development

No branches or pull requests

3 participants