Rebounce navigation events

This commit is contained in:
2026-01-30 12:26:36 +01:00
parent 5ce6b0c417
commit d3d26c6ae1
8 changed files with 56 additions and 26 deletions

View File

@@ -19,16 +19,23 @@ let {
let dialog: Dialog = $state()
let node: FSNode = $state(null)
export const open = async (n: FSNode, target: EventTarget) => {
export const open = async (n: FSNode, target: EventTarget, event: Event) => {
node = n
let el: HTMLElement = (target as Element).closest("button")
if (el === null) {
el = (target as Element).closest("a")
}
// Wait for the view to update, so the dialog gets the proper measurements
await tick()
dialog.open(el.getBoundingClientRect())
let el: HTMLElement = (target as Element).closest("button")
if (el !== null) {
dialog.open(el.getBoundingClientRect())
return
}
if (event instanceof MouseEvent) {
dialog.open(event)
return
}
console.error("Cannot find suitable target for spawning dialog window")
}
const delete_node = async () => {