diff --git a/src/app/page.tsx b/src/app/page.tsx index 50fc536d..eb4c58b7 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -36,8 +36,8 @@ export default function Home() { >(undefined); // maps ref and state - const mapRef = useRef(null); const [mapTitle, setMapTitle] = useState(undefined); + const mapRef = useRef(null); const [geojsonWithStyleList, setGeojsonWithStyleList] = useState< Array<{ id: string; style: TridentMapsStyle; geojson: FeatureCollection }> >([]); @@ -156,7 +156,9 @@ export default function Home() { } = parseInnerResJson(innerResJson); if (linesWithTitle.length > 0) { - setMapTitle(linesWithTitle[0].split(":")[1]); + const newMapTitle = linesWithTitle[0].split(":")[1]; + setMapTitle(newMapTitle); + setPageTitle(newMapTitle ? `${newMapTitle} | TRIDENT` : "TRIDENT"); } linesWithAreaAndOrConcern.map(async (line: string, idx: number) => { @@ -227,18 +229,6 @@ export default function Home() { [inputText, insertNewDialogue, pastMessages, scrollToBottom] ); - const onSelectSuggestions = useCallback( - async (value: string) => { - setResponding(true); - await onSubmit(value); - }, - [onSubmit] - ); - - useEffect(() => { - setPageTitle(mapTitle ? `${mapTitle} | TRIDENT` : "TRIDENT"); - }, [mapTitle]); - // fit bounds to all geojson in the geojsonWithStyleList useEffect(() => { setTimeout(() => { @@ -394,7 +384,10 @@ export default function Home() { {dialogueList.length === 1 && inputText.length === 0 && ( { + setInputText(value); + onSubmit(value); + }} onChangeLocation={(v) => { setLocation(v); }} @@ -409,7 +402,10 @@ export default function Home() { onUpdateSuggestions={() => { scrollToBottom(); }} - onSelect={onSelectSuggestions} + onSelect={(value: string) => { + setInputText(value); + onSubmit(value); + }} /> )}