@wentools/overlay 0.1.4 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/popover.svelte +12 -7
package/package.json
CHANGED
package/src/popover.svelte
CHANGED
|
@@ -237,18 +237,23 @@ Perfect for: building custom popover patterns, tooltips, custom dropdowns.
|
|
|
237
237
|
}
|
|
238
238
|
}
|
|
239
239
|
|
|
240
|
-
//
|
|
241
|
-
//
|
|
240
|
+
// Ignore clicks shortly after opening so a programmatic open from pointerdown
|
|
241
|
+
// isn't closed by the click from the same tap. On touch devices, pointerdown
|
|
242
|
+
// and the compatibility click fire in separate browser tasks, so rAF-based
|
|
243
|
+
// deferral isn't sufficient — a time-based guard is needed instead.
|
|
242
244
|
$effect(() => {
|
|
243
245
|
if (!open || !closeOnClickOutside) return
|
|
244
246
|
|
|
245
|
-
const
|
|
246
|
-
|
|
247
|
-
|
|
247
|
+
const openedAt = performance.now()
|
|
248
|
+
const guardedHandler = (event: MouseEvent) => {
|
|
249
|
+
if (performance.now() - openedAt < 300) return
|
|
250
|
+
handleClickOutside(event)
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
document.addEventListener('click', guardedHandler)
|
|
248
254
|
|
|
249
255
|
return () => {
|
|
250
|
-
|
|
251
|
-
document.removeEventListener('click', handleClickOutside)
|
|
256
|
+
document.removeEventListener('click', guardedHandler)
|
|
252
257
|
}
|
|
253
258
|
})
|
|
254
259
|
|