diff --git a/mobile/src/host-route-exit.test.ts b/mobile/src/host-route-exit.test.ts index 2856faa7e..ac9231a7b 100644 --- a/mobile/src/host-route-exit.test.ts +++ b/mobile/src/host-route-exit.test.ts @@ -4,16 +4,18 @@ import { leaveHostRoute } from './host-route-exit' function makeRouter() { return { - replace: vi.fn() + dismissTo: vi.fn() } } describe('leaveHostRoute', () => { - it('returns to home instead of depending on route history', () => { + // Why: dismissTo (not replace) is what makes the chevron animate back like swipe-back, so the + // call shape is the behavior under test, not an implementation detail. + it('dismisses to home instead of depending on route history', () => { const router = makeRouter() leaveHostRoute(router) - expect(router.replace).toHaveBeenCalledWith('/') + expect(router.dismissTo).toHaveBeenCalledWith('/') }) }) diff --git a/mobile/src/host-route-exit.ts b/mobile/src/host-route-exit.ts index 438da03c1..a5ffee421 100644 --- a/mobile/src/host-route-exit.ts +++ b/mobile/src/host-route-exit.ts @@ -1,9 +1,10 @@ type HostRouteExitRouter = { - replace: (href: '/') => void + dismissTo: (href: '/') => void } export function leaveHostRoute(router: HostRouteExitRouter): void { - // Why: direct pairing can open /h/:hostId as the root route, and split-view - // detail history is not the host/home screen the header is meant to exit to. - router.replace('/') + // Why: direct pairing can open /h/:hostId as the root route, and split-view detail history is + // not the host/home screen the header is meant to exit to. dismissTo pops to home when it is on + // the stack, so the chevron animates back like swipe-back, and replaces when it is not. + router.dismissTo('/') }