refactor(ui): update BasePane to use clickOutside action

Replace manual click event listener with clickOutside action for the
pane backdrop click handling. This simplifies the code and ensures
consistent click-outside behavior.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Justin Edmund 2025-10-07 22:00:54 -07:00
parent 7300bd672b
commit dcca9eb6e5

View file

@ -1,5 +1,6 @@
<script lang="ts">
import { fade } from 'svelte/transition'
import { clickOutside } from '$lib/actions/clickOutside'
import type { Snippet } from 'svelte'
interface BasePaneProps {
@ -40,24 +41,6 @@
return () => window.removeEventListener('keydown', handleKeydown)
})
// Handle click outside
$effect(() => {
if (!isOpen || !closeOnBackdrop) return
function handleClickOutside(e: MouseEvent) {
if (paneElement && !paneElement.contains(e.target as Node)) {
handleClose()
}
}
// Use capture phase to ensure we catch the click before other handlers
setTimeout(() => {
document.addEventListener('click', handleClickOutside, true)
}, 0)
return () => document.removeEventListener('click', handleClickOutside, true)
})
function handleClose() {
isOpen = false
onClose?.()
@ -133,6 +116,8 @@
transition:fade={{ duration: 150 }}
role="dialog"
aria-modal="false"
use:clickOutside={{ enabled: closeOnBackdrop }}
on:clickoutside={handleClose}
>
{#if children}
{@render children()}