Skip to content

Commit 2024281

Browse files
committed
fix: use post flush in modal example
1 parent 3234c59 commit 2024281

File tree

2 files changed

+163
-65
lines changed

2 files changed

+163
-65
lines changed

e2e/modal/index.ts

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ async function showUserModal(id: number) {
2525
params: { id: '' + id },
2626
state: { backgroundView },
2727
})
28+
const newState = {
29+
...window.history.state,
30+
backgroundView,
31+
}
32+
window.history.___replaceState(newState, '')
2833
}
2934

3035
function closeUserModal() {
@@ -64,20 +69,23 @@ const Home = defineComponent({
6469

6570
const userId = computed(() => route.params.id)
6671

67-
watchEffect(() => {
68-
const el = modal.value
69-
if (!el) return
70-
71-
const show = historyState.value.backgroundView
72-
console.log('show modal?', show)
73-
if (show) {
74-
if ('show' in el) el.show()
75-
else el.setAttribute('open', '')
76-
} else {
77-
if ('close' in el) el.close()
78-
else el.removeAttribute('open')
79-
}
80-
})
72+
watchEffect(
73+
() => {
74+
const el = modal.value
75+
if (!el) return
76+
77+
const show = historyState.value.backgroundView
78+
console.log('show modal?', show)
79+
if (show) {
80+
if ('show' in el) el.show()
81+
else el.setAttribute('open', '')
82+
} else {
83+
if ('close' in el) el.close()
84+
else el.removeAttribute('open')
85+
}
86+
},
87+
{ flush: 'post' }
88+
)
8189

8290
return {
8391
modal,

0 commit comments

Comments
 (0)