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(planner): clear place search input when modal closes

Luffy4f5a6bb7d84f
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(<PlaceFormModal {...defaultProps} isOpen />);
+ await user.type(screen.getByPlaceholderText('Search places...'), 'Eiffel Tower');
+
+ rerender(<PlaceFormModal {...defaultProps} isOpen={false} />);
+ rerender(<PlaceFormModal {...defaultProps} isOpen />);
+
+ 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(() => {