TypeScript
fix: close the event popover when its anchor scrolls away
Vipul Kumar0201ad73c773
diff --git a/src/components/calendar/time-grid.tsx b/src/components/calendar/time-grid.tsxindex 9468649..3f1ad10 100644--- a/src/components/calendar/time-grid.tsx+++ b/src/components/calendar/time-grid.tsx@@ -239,7 +239,11 @@ export function TimeGrid({ days }: { days: string[] }) {<><DayHeaders days={days} /><AllDayRow days={days} axisWidth={AXIS_WIDTH} />- <div ref={scrollRef} className="relative min-h-0 w-full flex-1 overflow-y-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden">+ <div+ ref={scrollRef}+ onScroll={() => useCalendarStore.getState().popover && useCalendarStore.getState().closePopover()}+ className="relative min-h-0 w-full flex-1 overflow-y-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden"+ >{/* Masks the line/label that sits exactly on the top edge when scrolled to an hour. */}<div className="pointer-events-none sticky top-0 z-20 h-0 w-full" aria-hidden><div className="absolute top-0 left-0 h-2 bg-surface" style={{ width: AXIS_WIDTH }} />diff --git a/src/components/time-off/time-off-view.tsx b/src/components/time-off/time-off-view.tsxindex 4b3dcdc..c16a1ec 100644--- a/src/components/time-off/time-off-view.tsx+++ b/src/components/time-off/time-off-view.tsx@@ -2,6 +2,7 @@import { useRef, useState } from "react";import { Calendar } from "@/components/calendar/calendar";+import { useCalendarStore } from "@/stores/calendar-store";import { DEFAULT_FILTERS, RequestsTable, type RequestFilters } from "./requests-table";import { StatsPanel } from "./stats-panel";@@ -13,7 +14,11 @@ export function TimeOffView() {const tableRef = useRef<HTMLElement>(null);return (- <div data-page-scroll className="scroll-thin flex min-h-0 flex-1 flex-col overflow-y-auto">+ <div+ data-page-scroll+ onScroll={() => useCalendarStore.getState().popover && useCalendarStore.getState().closePopover()}+ className="scroll-thin flex min-h-0 flex-1 flex-col overflow-y-auto"+ ><divclassName="flex w-full shrink-0 overflow-hidden"style={{ height: `max(520px, calc(100% - ${REQUESTS_PEEK}px))` }}