mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-18 21:16:47 +00:00
fix(planner): clear place search input when modal closes
This commit is contained in:
@@ -162,6 +162,17 @@ describe('PlaceFormModal', () => {
|
|||||||
expect(screen.queryByDisplayValue('Old Place')).not.toBeInTheDocument();
|
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 ──────────────────────────────────────────────────────────────
|
// ── Maps search ──────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
it('FE-PLANNER-PLACEFORM-018: maps search populates results via button click', async () => {
|
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
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [place, prefillCoords, isOpen, assignmentId])
|
}, [place, prefillCoords, isOpen, assignmentId])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!isOpen) {
|
||||||
|
setMapsSearch('')
|
||||||
|
}
|
||||||
|
}, [isOpen])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isOpen) {
|
if (isOpen) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user