Skip to content

Commit 93c7d99

Browse files
committed
fix(async-stack): clickoutside bound should be of dialog element itself
1 parent 52a89aa commit 93c7d99

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

.changeset/tasty-chefs-dress.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@svelte-put/async-stack': patch
3+
---
4+
5+
correct clickoutside logic in enhance-dialog attachment

packages/async-stack/src/helpers/enhance-dialog.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export function enhanceDialog(item, options) {
3939
if (dialog.open) {
4040
// user calls `item.resolve(...)`
4141
dialog.removeEventListener('close', onclose);
42+
// TODO: change to https://developer.mozilla.org/en-US/docs/Web/API/HTMLDialogElement/requestClose
4243
dialog.close();
4344
}
4445
resumeResolution = resolve;
@@ -82,7 +83,7 @@ export function enhanceDialog(item, options) {
8283
*/
8384
function onclick(event) {
8485
const dialog = /** @type {HTMLDialogElement} */ (event.currentTarget);
85-
const rect = /** @type {HTMLDialogElement} */ (event.target).getBoundingClientRect();
86+
const rect = dialog.getBoundingClientRect();
8687
if (!event.clientX || !event.clientY) return; // not a mouse event (probably triggered by keyboard)
8788
if (
8889
rect.left > event.clientX ||

0 commit comments

Comments
 (0)