From 4f5a6bb7d84fe35e300756d4dd0f6939541c73a2 Mon Sep 17 00:00:00 2001 From: Luffy Date: Tue, 22 Sep 2026 15:50:13 +0800 Subject: [PATCH] fix(planner): clear place search input when modal closes --- client/src/components/Planner/PlaceFormModal.test.tsx | 11 +++++++++++ client/src/components/Planner/PlaceFormModal.tsx | 6 ++++++ 2 files changed, 17 insertions(+) diff --git a/client/src/components/Planner/PlaceFormModal.test.tsx b/client/src/components/Planner/PlaceFormModal.test.tsx index ed2595354..40fbc45e1 100644 --- a/client/src/components/Planner/PlaceFormModal.test.tsx +++ b/client/src/components/Planner/PlaceFormModal.test.tsx @@ -162,6 +162,17 @@ describe('PlaceFormModal', () => { expect(screen.queryByDisplayValue('Old Place')).not.toBeInTheDocument(); }); + it('clears the maps search input after the modal closes and reopens', async () => { + const user = userEvent.setup(); + const { rerender } = render(); + await user.type(screen.getByPlaceholderText('Search places...'), 'Eiffel Tower'); + + rerender(); + rerender(); + + expect(screen.getByPlaceholderText('Search places...')).toHaveValue(''); + }); + // ── Maps search ────────────────────────────────────────────────────────────── it('FE-PLANNER-PLACEFORM-018: maps search populates results via button click', async () => { diff --git a/client/src/components/Planner/PlaceFormModal.tsx b/client/src/components/Planner/PlaceFormModal.tsx index 781d62654..97843bb2d 100644 --- a/client/src/components/Planner/PlaceFormModal.tsx +++ b/client/src/components/Planner/PlaceFormModal.tsx @@ -318,6 +318,12 @@ function usePlaceFormModal(props: PlaceFormModalProps) { // eslint-disable-next-line react-hooks/exhaustive-deps }, [place, prefillCoords, isOpen, assignmentId]) + useEffect(() => { + if (!isOpen) { + setMapsSearch('') + } + }, [isOpen]) + useEffect(() => { if (isOpen) { setTimeout(() => {