Skip to content

Commit 4cfc8b9

Browse files
committed
fix: fixed focus, blur and disableBodyScroll timing
1 parent ab8cac3 commit 4cfc8b9

File tree

2 files changed

+10
-15
lines changed

2 files changed

+10
-15
lines changed

packages/vue-final-modal/src/components/CoreModal/CoreModal.vue

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,18 +75,12 @@ const {
7575
leaveTransition,
7676
} = useTransition(props, {
7777
modelValueLocal,
78-
async onEntering() {
78+
onEnter() {
7979
focus()
80-
await nextTick()
8180
disableBodyScroll()
82-
},
83-
onEnter() {
8481
emitEvent('opened')
8582
resolveToggle('opened')
8683
},
87-
onLeaving() {
88-
blur()
89-
},
9084
onLeave() {
9185
deleteFromOpenedModals(getModalInstance())
9286
focusLast()
@@ -158,6 +152,7 @@ function close() {
158152
enableBodyScroll()
159153
deleteFromOpenedModalOverlays(modalInstance)
160154
openLastOverlay()
155+
blur()
161156
leaveTransition()
162157
}
163158

packages/vue-final-modal/src/components/CoreModal/useTransition.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ export function useTransition(
3434
props: InstanceType<typeof CoreModal>['$props'],
3535
options: {
3636
modelValueLocal: Ref<boolean>
37-
onEntering: () => void
38-
onEnter: () => void
39-
onLeaving: () => void
40-
onLeave: () => void
37+
onEntering?: () => void
38+
onEnter?: () => void
39+
onLeaving?: () => void
40+
onLeave?: () => void
4141
},
4242
): {
4343
visible: Ref<boolean>
@@ -83,13 +83,13 @@ export function useTransition(
8383
watch(contentState, (state) => {
8484
switch (state) {
8585
case TransitionState.Entering:
86-
return onEntering()
86+
return onEntering?.()
8787
case TransitionState.Enter:
88-
return onEnter()
88+
return onEnter?.()
8989
case TransitionState.Leaving:
90-
return onLeaving()
90+
return onLeaving?.()
9191
case TransitionState.Leave:
92-
return onLeave()
92+
return onLeave?.()
9393
}
9494
})
9595

0 commit comments

Comments
 (0)