Skip to content

Self-hosted personal gallery application with online photo management and albums, supporting Live/Motion Photos, EXIF parsing, geolocation recognition, and an explore map.

fix(floating-window): close on Escape only when focus is inside the window

coderabbitai[bot]8fb3126ff945
diff --git a/app/components/ui/FloatingWindow/FloatingWindow.vue b/app/components/ui/FloatingWindow/FloatingWindow.vue
index c4aaec77..3d7abc46 100644
--- a/app/components/ui/FloatingWindow/FloatingWindow.vue
+++ b/app/components/ui/FloatingWindow/FloatingWindow.vue
@@ -31,6 +31,7 @@ const props = withDefaults(
},
)
const open = defineModel<boolean>({ default: true })
+const windowEl = ref<HTMLElement | null>(null)
const rect = ref<FloatingRect>({
x: props.initialX,
y: props.initialY,
@@ -139,7 +140,12 @@ function startGesture(event: PointerEvent, edge?: string) {
stopGesture = stop
}
function handleKey(event: KeyboardEvent) {
- if (open.value && event.key === 'Escape' && !event.defaultPrevented)
+ if (
+ open.value &&
+ event.key === 'Escape' &&
+ !event.defaultPrevented &&
+ windowEl.value?.contains(document.activeElement)
+ )
open.value = false
}
onMounted(() => {
@@ -197,6 +203,7 @@ onBeforeUnmount(() => {
>
<section
v-if="open && ready"
+ ref="windowEl"
role="dialog"
tabindex="-1"
:aria-label="title"
diff --git a/docs/development/debug-tools.md b/docs/development/debug-tools.md
index a7d77ccd..979ce4d7 100644
--- a/docs/development/debug-tools.md
+++ b/docs/development/debug-tools.md
@@ -64,4 +64,4 @@ keep the window inside the viewport. Configure `minWidth`, `minHeight`,
small screens. Maximization fills the viewport and preserves the normal rect.
Slots: default content, `title`, `actions`, and `footer`.
-Validation: `node --test tests/debug-tools.test.mjs`.
+Validation: `pnpm lint`.