fix(Modal/Slideover): don't emit close:prevent on closeAutoFocus

This commit is contained in:
Benjamin Canac
2025-06-05 17:22:42 +02:00
parent bf56e15a2e
commit 150b334b1d
3 changed files with 10 additions and 9 deletions

View File

@@ -104,15 +104,15 @@ const contentEvents = computed(() => {
}
if (!props.dismissible) {
const events = ['pointerDownOutside', 'interactOutside', 'escapeKeyDown', 'closeAutoFocus'] as const
type EventType = typeof events[number]
const events = ['pointerDownOutside', 'interactOutside', 'escapeKeyDown']
return events.reduce((acc, curr) => {
acc[curr] = (e: Event) => {
e.preventDefault()
emits('close:prevent')
}
return acc
}, {} as Record<EventType, (e: Event) => void>)
}, defaultEvents as Record<typeof events[number] | keyof typeof defaultEvents, (e: Event) => void>)
}
return defaultEvents

View File

@@ -75,15 +75,15 @@ const portalProps = usePortal(toRef(() => props.portal))
const contentProps = toRef(() => defu(props.content, { side: 'bottom', sideOffset: 8, collisionPadding: 8 }) as PopoverContentProps)
const contentEvents = computed(() => {
if (!props.dismissible) {
const events = ['pointerDownOutside', 'interactOutside', 'escapeKeyDown'] as const
type EventType = typeof events[number]
const events = ['pointerDownOutside', 'interactOutside', 'escapeKeyDown']
return events.reduce((acc, curr) => {
acc[curr] = (e: Event) => {
e.preventDefault()
emits('close:prevent')
}
return acc
}, {} as Record<EventType, (e: Event) => void>)
}, {} as Record<typeof events[number], (e: Event) => void>)
}
return {}

View File

@@ -103,16 +103,17 @@ const contentEvents = computed(() => {
const defaultEvents = {
closeAutoFocus: (e: Event) => e.preventDefault()
}
if (!props.dismissible) {
const events = ['pointerDownOutside', 'interactOutside', 'escapeKeyDown', 'closeAutoFocus'] as const
type EventType = typeof events[number]
const events = ['pointerDownOutside', 'interactOutside', 'escapeKeyDown']
return events.reduce((acc, curr) => {
acc[curr] = (e: Event) => {
e.preventDefault()
emits('close:prevent')
}
return acc
}, {} as Record<EventType, (e: Event) => void>)
}, defaultEvents as Record<typeof events[number] | keyof typeof defaultEvents, (e: Event) => void>)
}
return defaultEvents