Skip to content

Commit

Permalink
fix(VOverlay): correct ShadowRoot attach condition
Browse files Browse the repository at this point in the history
fixes #20001
fixes #20086
  • Loading branch information
KaelWD committed Jul 3, 2024
1 parent be3e401 commit ec73e6f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
10 changes: 7 additions & 3 deletions packages/vuetify/src/components/VOverlay/VOverlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,13 @@ export const VOverlay = genericComponent<OverlaySlots>()({
contentEvents,
scrimEvents,
} = useActivator(props, { isActive, isTop: localTop })
const potentialShadowDomRoot = computed(() => (activatorEl?.value as Element)?.getRootNode() as Element)
const { teleportTarget } = useTeleport(computed(() => props.attach || props.contained ||
potentialShadowDomRoot.value instanceof ShadowRoot ? potentialShadowDomRoot.value ?? true : false))
const { teleportTarget } = useTeleport(() => {
const target = props.attach || props.contained
if (target) return target
const rootNode = activatorEl?.value?.getRootNode()
if (rootNode instanceof ShadowRoot) return rootNode
return false
})
const { dimensionStyles } = useDimension(props)
const isMounted = useHydration()
const { scopeId } = useScopeId()
Expand Down
7 changes: 2 additions & 5 deletions packages/vuetify/src/composables/teleport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@
import { computed, warn } from 'vue'
import { IN_BROWSER } from '@/util'

// Types
import type { Ref } from 'vue'

export function useTeleport (target: Ref<boolean | string | Element>) {
export function useTeleport (target: () => (boolean | string | ParentNode)) {
const teleportTarget = computed(() => {
const _target = target.value
const _target = target()

if (_target === true || !IN_BROWSER) return undefined

Expand Down

0 comments on commit ec73e6f

Please sign in to comment.