fix(roadtrip): the stop popup shows the answers of the stop it is handed, not the previous one

The desktop road trip stop popup read its kind, length, night and
check-in answers only when it mounted. When the planner handed the open
popup another stop draft, the popup showed the new stop's name with the
previous stop's kind, length, night switch and check-in, and saving wrote
those stale answers onto the new stop.

The phone sheet already seeds the shared useStopDraftForm again for
every draft. The popup now does the same in an effect keyed on the draft,
and seeds the night switch and the check-in time from the same draft.

Red test: FE-ROADTRIP-STOPPOPUP-034 in
client/src/components/Roadtrip/RoadtripStopPopup.test.tsx failed with
expect(element).toHaveAttribute("aria-pressed", "true") on the Charging
chip after the draft was swapped.

No existing assertions changed.
This commit is contained in:
Maurice
2026-10-09 17:56:27 +02:00
parent 8c9a31e5ef
commit 55e6b55f4d
3 changed files with 41 additions and 6 deletions
@@ -24,8 +24,8 @@ export function stopDraftDefaults(draft: RoadtripStopDraft | null | undefined):
/**
* The two questions a stop found along the drive answers before it goes onto the trip,
* what kind it is and how long it takes, behind the desktop stop popup and the phone's
* draft sheet. `initialDraft` gives the first answers; the phone seeds them again for
* every draft it is handed.
* draft sheet. `initialDraft` gives the first answers; both seed them again with
* `seed` for every draft they are handed while they stay open.
*/
export function useStopDraftForm(initialDraft: RoadtripStopDraft | null) {
const [stopType, setStopType] = useState<RoadtripStopType | null>(() => stopDraftDefaults(initialDraft).stopType);