Skip to content

Commit 8814a1e

Browse files
fix(focus-scope): add data-focus-scope-unmounting attribute during focus restoration (#2631)
1 parent 333707d commit 8814a1e

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

packages/core/src/FocusScope/FocusScope.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,10 @@ watchEffect(async (cleanupFn) => {
185185
container.addEventListener(AUTOFOCUS_ON_UNMOUNT, unmountEventHandler)
186186
container.dispatchEvent(unmountEvent)
187187
188+
// Signal that blur events fired below are system-initiated (focus trap
189+
// cleanup), not user-initiated. Consumers can use this to skip validation.
190+
container.setAttribute('data-focus-scope-unmounting', '')
191+
188192
setTimeout(() => {
189193
if (!unmountEvent.defaultPrevented)
190194
focus(previouslyFocusedElement ?? document.body, { select: true })
@@ -193,6 +197,7 @@ watchEffect(async (cleanupFn) => {
193197
container.removeEventListener(AUTOFOCUS_ON_UNMOUNT, unmountEventHandler)
194198
195199
focusScopesStack.remove(focusScope)
200+
container.removeAttribute('data-focus-scope-unmounting')
196201
}, 0)
197202
})
198203
})

0 commit comments

Comments
 (0)