fix(planner): clear place search input when modal closes

This commit is contained in:
Luffy
2026-09-22 15:50:13 +08:00
committed by Maurice
parent d609e1e202
commit 4f5a6bb7d8
2 changed files with 17 additions and 0 deletions
@@ -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 () => {
@@ -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(() => {