The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.
TypeScript budget-trackercollaborativedockeritinerarymcp-serveroffline-firstopen-sourceopenstreetmappacking-listpwareal-timeself-hostedselfhostedtraveltravel-apptravel-journaltravel-plannertripitwanderlog
fix(mobile): a day tapped in the day rail moves the pager on short trips too
Mauriceb124e1bc9ca0
diff --git a/client/src/mobile/components/MDayPager.test.tsx b/client/src/mobile/components/MDayPager.test.tsxindex 2b6083e82..c3ec4a657 100644--- a/client/src/mobile/components/MDayPager.test.tsx+++ b/client/src/mobile/components/MDayPager.test.tsx@@ -199,6 +199,39 @@ describe('MDayPager', () => {expect(strip.scrollLeft).toBe(390);});+ it('moves the strip to a day tapped inside the same window, as on a two-day trip', () => {+ const twoDays = DAYS.slice(0, 2);+ const { strip, rerender, onSelectDay } = setup(1, { days: twoDays });+ let scrollLeft = 0;+ Object.defineProperty(strip, 'scrollLeft', {+ configurable: true,+ get: () => scrollLeft,+ set: (v) => {+ scrollLeft = v;+ },+ });+ // Both days are in the window either way; only the current page changes.+ const realQuery = strip.querySelector.bind(strip);+ vi.spyOn(strip, 'querySelector').mockImplementation((sel: string) => {+ const el = realQuery(sel) as HTMLElement | null;+ if (el && sel === '[data-page-active]') el.getBoundingClientRect = () => ({ left: 390 }) as DOMRect;+ return el;+ });+ strip.getBoundingClientRect = () => ({ left: 0 }) as DOMRect;++ rerender(+ <MDayPager+ days={twoDays}+ selectedDayId={2}+ onSelectDay={onSelectDay}+ describeDay={() => ''}+ renderDay={(dayId) => <p>{`page ${dayId}`}</p>}+ />+ );++ expect(strip.scrollLeft).toBe(390);+ });+it('holds still while locked', () => {const { strip } = setup(2, { locked: true });expect(strip).toHaveClass('overflow-x-hidden');diff --git a/client/src/mobile/components/MDayPager.tsx b/client/src/mobile/components/MDayPager.tsxindex 303f44e69..2e119e5b7 100644--- a/client/src/mobile/components/MDayPager.tsx+++ b/client/src/mobile/components/MDayPager.tsx@@ -71,7 +71,10 @@ export default function MDayPager({const stripRef = useRef<HTMLDivElement>(null);const [announcement, setAnnouncement] = useState('');const pages = pagesFor(days, selectedDayId);- const windowKey = pages.map((p) => p.key).join(',');+ // Which page is current belongs in the key: on a trip of up to five days a+ // chip tap can keep the same pages, and the strip then stayed on the old day+ // while the rail already showed the new one.+ const windowKey = pages.map((p) => (p.active ? `*${p.key}` : p.key)).join(',');// The handlers below are attached once, so they read the props through here.const latest = useRef({ days, onSelectDay, describeDay, selectedDayId, onPreview });@@ -91,7 +94,7 @@ export default function MDayPager({if (Math.abs(offset) > 0.5) strip.scrollLeft += offset;}, []);- // Before paint whenever the window moves: a landed swipe or a chip tap.+ // Before paint whenever the window or its current page moves: a landed swipe or a chip tap.useLayoutEffect(() => {requested.current = null;recentre();