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.
TypeScript budget-trackercollaborativedockeritinerarymcp-serveroffline-firstopen-sourceopenstreetmappacking-listpwareal-timeself-hostedselfhostedtraveltravel-apptravel-journaltravel-plannertripitwanderlog
fix(mobile): search a map link shared while the add-place sheet is already open
Maurice5685cdfe133f
diff --git a/client/src/components/Planner/usePlaceSearch.ts b/client/src/components/Planner/usePlaceSearch.tsindex a846bc8a5..0b3d8e09f 100644--- a/client/src/components/Planner/usePlaceSearch.ts+++ b/client/src/components/Planner/usePlaceSearch.ts@@ -268,11 +268,12 @@ export function usePlaceSearch({const pickPlace = (place: MapsPlace, pick?: PlaceSearchPick) =>take(place, pick, sourceLabel(place, pick?.mode === 'search' ? searchSource : ''));- const runSearch = async (provider?: 'google') => {+ const runSearch = async (provider?: 'google', text?: string) => {// The retry sends the query the list came from, not the field: the list// stays on screen while the field is edited or cleared, and the line under- // it promises the same query.- const trimmed = provider ? (searchMetaRef.current?.query ?? '') : query.trim();+ // it promises the same query. A link shared into an open sheet is searched+ // as given, before the field shows it.+ const trimmed = provider ? (searchMetaRef.current?.query ?? '') : (text ?? query).trim();if (!trimmed) return;if (sheet) {setSuggestions([]);diff --git a/client/src/mobile/screens/trip/sheets/PlPlaceSearch.tsx b/client/src/mobile/screens/trip/sheets/PlPlaceSearch.tsxindex a16248bc0..6ba4dde4c 100644--- a/client/src/mobile/screens/trip/sheets/PlPlaceSearch.tsx+++ b/client/src/mobile/screens/trip/sheets/PlPlaceSearch.tsx@@ -103,13 +103,15 @@ export default function PlPlaceSearch({ planner, locationBias, onPick, onSuggest})// A map link shared to the app (#2582) is looked up as soon as the sheet opens,- // as if it had been pasted and searched.- const runInitial = useEffectEvent(() => {- void handleSearch()+ // as if it had been pasted and searched. The sheet may be open already, its+ // field holding something else, so the link itself is what is searched.+ const runInitial = useEffectEvent((link: string) => {+ setQuery(link)+ void handleSearch(undefined, link)onInitialQueryRun?.()})useEffect(() => {- if (initialQuery) runInitial()+ if (initialQuery) runInitial(initialQuery)}, [initialQuery])return (diff --git a/client/tests/unit/mobile/trip/PlPlaceSearch.test.tsx b/client/tests/unit/mobile/trip/PlPlaceSearch.test.tsxindex f6c781768..c0e6d6eab 100644--- a/client/tests/unit/mobile/trip/PlPlaceSearch.test.tsx+++ b/client/tests/unit/mobile/trip/PlPlaceSearch.test.tsx@@ -271,6 +271,29 @@ describe('PlPlaceSearch', () => {expect(autocompleteBodies).toHaveLength(0)})+ it('FE-MOB-PLSRCH-010b: a link shared while the sheet is open is resolved, whatever the field held', async () => {+ const resolved: string[] = []+ server.use(+ recordAutocomplete(),+ recordSearch(),+ http.post('/api/maps/resolve-url', async ({ request }) => {+ resolved.push(((await request.json()) as { url: string }).url)+ return HttpResponse.json({ lat: 48.86, lng: 2.33, name: 'Louvre', address: 'Paris' })+ }),+ )+ const { input, onPick, planner, rerender, onSuggestionName, onResolvingChange } = setup()+ fireEvent.change(input, { target: { value: 'cafe' } })+ const onInitialQueryRun = vi.fn()+ rerender(+ <PlPlaceSearch planner={planner} onPick={onPick} onSuggestionName={onSuggestionName} onResolvingChange={onResolvingChange} initialQuery="https://maps.app.goo.gl/abc" onInitialQueryRun={onInitialQueryRun} />,+ )++ await waitFor(() => expect(onPick).toHaveBeenCalledWith(expect.objectContaining({ name: 'Louvre', lat: '48.86', lng: '2.33' })))+ expect(resolved).toEqual(['https://maps.app.goo.gl/abc'])+ expect(searchBodies).toHaveLength(0)+ expect(onInitialQueryRun).toHaveBeenCalledTimes(1)+ })+it('FE-MOB-PLSRCH-011: falls through to the text search when the URL carries no coordinates', async () => {server.use(http.post('/api/maps/resolve-url', () => HttpResponse.json({ lat: null, lng: null })),