Skip to content

Commit

Permalink
fix(VOverlay): click outside only applies to scrim (vuetifyjs#19393)
Browse files Browse the repository at this point in the history
fixes vuetifyjs#18384

Co-authored-by: John Leider <john@vuetifyjs.com>
  • Loading branch information
MetRonnie and johnleider authored Mar 19, 2024
1 parent 0167be4 commit 03b66fa
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 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 Expand Up @@ -332,6 +337,7 @@ export const VOverlay = genericComponent<OverlaySlots>()({

return {
activatorEl,
scrimEl,
target,
animateClick,
contentEl,
Expand Down

0 comments on commit 03b66fa

Please sign in to comment.