Skip to content

Commit dc6a91c

Browse files
committed
fix: prevent modal closing on inner clicks
1 parent 1c8e14b commit dc6a91c

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

app/app.vue

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,14 @@ function handleGlobalKeyup() {
7474
function handleModalLightDismiss(e: MouseEvent) {
7575
const target = e.target as HTMLElement
7676
if (target.tagName === 'DIALOG' && target.hasAttribute('open')) {
77+
const rect = target.getBoundingClientRect()
78+
const isOutside =
79+
e.clientX < rect.left ||
80+
e.clientX > rect.right ||
81+
e.clientY < rect.top ||
82+
e.clientY > rect.bottom
83+
84+
if (!isOutside) return
7785
;(target as HTMLDialogElement).close()
7886
}
7987
}

0 commit comments

Comments
 (0)