diff --git a/src/lib/components/LocationDialog.svelte b/src/lib/components/LocationDialog.svelte index 6a68684..538ed2c 100644 --- a/src/lib/components/LocationDialog.svelte +++ b/src/lib/components/LocationDialog.svelte @@ -46,9 +46,13 @@ const title = $derived(feature?.name ?? savedPoint?.label ?? 'New location'); const rows = $derived(feature?.rows ?? []); - // Clamp the dialog within 40px of the map edges. - const LEFT = $derived(Math.min(Math.max(x, 8), window.innerWidth - 320)); - const TOP = $derived(Math.min(Math.max(y, 8), window.innerHeight - 260)); + // Position the dialog so its 16x16 arrow points at the click. + // Shift 8px left (arrow center lands on the click X via the 50% translate) + // and 16px down (bubble body sits under the arrow tip at the click Y). + const ARROW_X = 8; + const ARROW_Y = 16; + const LEFT = $derived(Math.min(Math.max(x - ARROW_X, 8), window.innerWidth - 320)); + const TOP = $derived(Math.min(Math.max(y + ARROW_Y, 8), window.innerHeight - 260)); function save() { onSavePoint(label.trim() ? label.trim() : undefined);