Skip to content

armgit / TREK

Public Imported from GitHub
0

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.

fix(mobile): switching collection lists changes the content in place instead of sliding a new page in

Maurice5fb1838c7a02
diff --git a/client/src/mobile/screens/collections/MCollections.tsx b/client/src/mobile/screens/collections/MCollections.tsx
index ae6e2e48c..092c5c3be 100644
--- a/client/src/mobile/screens/collections/MCollections.tsx
+++ b/client/src/mobile/screens/collections/MCollections.tsx
@@ -26,6 +26,7 @@ import { STATUS_SPEC } from './collectionsMobileModel'
import MConfirmSheet from '../settings/MConfirmSheet'
import MCollListNav from './MCollListNav'
import { useIsSplit } from '../../../hooks/sizeClass'
+import { skipNextRouteTransition } from '../../routeTransition'
const HEADER_CIRCLE =
'flex h-[38px] w-[38px] flex-none items-center justify-center rounded-full border border-[color:var(--m-gbr)] bg-[color:var(--m-sheet)] text-m-ink shadow-[0_5px_12px_-8px_rgba(0,0,0,.18)]'
@@ -133,6 +134,9 @@ export default function MCollections() {
const selectList = (id: number | typeof ALL_SAVED) => {
setDrop(false)
+ // Another list is the same screen with other content, not a page opened
+ // over it: the URL changes, but the page must not slide in.
+ skipNextRouteTransition()
c.handleSelectList(id)
}
diff --git a/client/tests/unit/mobile/collections/MCollections.test.tsx b/client/tests/unit/mobile/collections/MCollections.test.tsx
index e6588f799..623822ace 100644
--- a/client/tests/unit/mobile/collections/MCollections.test.tsx
+++ b/client/tests/unit/mobile/collections/MCollections.test.tsx
@@ -8,6 +8,8 @@ import { ALL_SAVED } from '../../../../src/store/collectionStore'
const mocks = vi.hoisted(() => ({ coll: {} as Record<string, unknown> }))
+const routeTransition = vi.hoisted(() => ({ skipNextRouteTransition: vi.fn() }))
+vi.mock('../../../../src/mobile/routeTransition', () => routeTransition)
vi.mock('../../../../src/pages/collections/useCollections', () => ({
useCollections: () => mocks.coll,
}))
@@ -268,6 +270,8 @@ describe('MCollections', () => {
fireEvent.click(screen.getByText('Julien Tipps'))
expect(fn('handleSelectList')).toHaveBeenCalledWith(2)
+ // Another list is the same screen: the URL change must not slide a page in.
+ expect(routeTransition.skipNextRouteTransition).toHaveBeenCalled()
// Picking closes the dropdown again.
expect(screen.queryByText('Julien Tipps')).not.toBeInTheDocument()
})