mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-24 07:53:09 +00:00
fix(journey): emptying the location field in the entry editor removes the location
The field showed the stored place as soon as the search query was empty, so deleting the last character snapped it back and the location could never be removed. Clearing the field now empties the place and its coordinates, closes the suggestions and drops any search answer that comes back afterwards. Typed text without a picked result keeps the stored location as before. The hook is shared, so the desktop dialog and the phone sheet both get the fix. Refs #2615
This commit is contained in:
@@ -1333,3 +1333,24 @@ describe('MJourneyEntrySheet clips', () => {
|
||||
expect(document.querySelectorAll('svg.lucide-play')).toHaveLength(1);
|
||||
});
|
||||
});
|
||||
|
||||
// FE-MOB-JENTRY-057: the phone half of the location field that snapped back (#2615).
|
||||
|
||||
describe('MJourneyEntrySheet location field', () => {
|
||||
it('FE-MOB-JENTRY-057: emptying the location keeps the field empty, drops the pin and saves no place', async () => {
|
||||
const user = userEvent.setup();
|
||||
const { onSave } = mountSheet(buildEntry({ id: 5, location_name: 'Rome', location_lat: 41.9, location_lng: 12.5 }));
|
||||
const input = screen.getByPlaceholderText('Search location...');
|
||||
expect(input).toHaveValue('Rome');
|
||||
expect(document.querySelector('svg.lucide-map-pin')).toBeInTheDocument();
|
||||
|
||||
fireEvent.change(input, { target: { value: 'Rom' } });
|
||||
fireEvent.change(input, { target: { value: '' } });
|
||||
expect(input).toHaveValue('');
|
||||
expect(document.querySelector('svg.lucide-map-pin')).not.toBeInTheDocument();
|
||||
|
||||
await user.click(screen.getByRole('button', { name: 'Save' }));
|
||||
await waitFor(() => expect(onSave).toHaveBeenCalled());
|
||||
expect(onSave.mock.calls[0][0]).toMatchObject({ location_name: null, location_lat: null, location_lng: null });
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user