Skip to content

Commit

Permalink
fix(VOverlay): click outside only applies to scrim
Browse files Browse the repository at this point in the history
fixes vuetifyjs#18384
Don't close on click outside if using scrim and the click is on an
element above the scrim.
  • Loading branch information
MetRonnie committed Mar 13, 2024
1 parent 9a76bfc commit a5d0564
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/vuetify/src/components/VOverlay/VOverlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ export const VOverlay = genericComponent<OverlaySlots>()({
})

const root = ref<HTMLElement>()
const scrimEl = ref<HTMLElement>()
const contentEl = ref<HTMLElement>()
const { contentStyles, updateLocation } = useLocationStrategies(props, {
isRtl,
Expand All @@ -184,8 +185,11 @@ export const VOverlay = genericComponent<OverlaySlots>()({
else animateClick()
}

function closeConditional () {
return isActive.value && globalTop.value
function closeConditional (e: Event) {
return isActive.value && globalTop.value && (
// If using scrim, only close if clicking on it rather than anything opened on top
!props.scrim || e.target === scrimEl.value
)
}

IN_BROWSER && watch(isActive, val => {
Expand Down Expand Up @@ -297,6 +301,7 @@ export const VOverlay = genericComponent<OverlaySlots>()({
<Scrim
color={ scrimColor }
modelValue={ isActive.value && !!props.scrim }
ref={ scrimEl }
{ ...scrimEvents.value }
/>
<MaybeTransition
Expand Down

0 comments on commit a5d0564

Please sign in to comment.