cleanup event listeners with solid-primitives/event-listener (#20619)

This commit is contained in:
Brendan Allan 2026-04-02 17:40:03 +08:00 committed by GitHub
commit 69d047ae7d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
22 changed files with 102 additions and 176 deletions

View file

@ -12,6 +12,7 @@ import {
type JSX,
} from "solid-js"
import { Dialog as Kobalte } from "@kobalte/core/dialog"
import { makeEventListener } from "@solid-primitives/event-listener"
type DialogElement = () => JSX.Element
@ -68,8 +69,7 @@ function init() {
event.stopPropagation()
}
window.addEventListener("keydown", onKeyDown, true)
onCleanup(() => window.removeEventListener("keydown", onKeyDown, true))
makeEventListener(window, "keydown", onKeyDown, { capture: true })
})
const show = (element: DialogElement, owner: Owner, onClose?: () => void) => {