@@ -257,24 +257,28 @@ const GeocodingSearch = forwardRef<GeocodingSearchHandle, GeocodingSearchProps>(
257257 const [ query , setQuery ] = useState ( "" ) ;
258258 const [ isFocused , setIsFocused ] = useState ( false ) ;
259259 const [ activeIndex , setActiveIndex ] = useState ( 0 ) ;
260+ const hasSearchableQuery =
261+ query . trim ( ) . length >= MAP_GEOCODING_MIN_QUERY_LENGTH ;
262+ const canShowResults = variant === "palette" || isFocused ;
263+ const showResults = hasSearchableQuery && canShowResults ;
260264 const { features, isError, isLoading, isReady } = useGeocodingSearch ( {
261265 query,
262266 countryCode,
267+ enabled : showResults ,
263268 proximity,
264269 } ) ;
265- const hasSearchableQuery =
266- query . trim ( ) . length >= MAP_GEOCODING_MIN_QUERY_LENGTH ;
267- const showResults =
268- hasSearchableQuery && ( variant === "palette" || isFocused ) ;
270+ const hasVisibleListbox = showResults && features . length > 0 ;
269271 const showNoResults =
270272 showResults && isReady && ! isLoading && ! isError && features . length === 0 ;
271- const statusMessage = isLoading
272- ? loadingMessage
273- : isError
274- ? error || errorMessage
275- : showNoResults
276- ? noResultsMessage
277- : "" ;
273+ const statusMessage = showResults
274+ ? isLoading
275+ ? loadingMessage
276+ : isError
277+ ? error || errorMessage
278+ : showNoResults
279+ ? noResultsMessage
280+ : ""
281+ : "" ;
278282 const shouldRenderStatusMessage =
279283 variant === "palette" || ! onStatusMessageChange ;
280284 const activeFeature = showResults ? features [ activeIndex ] : undefined ;
@@ -345,8 +349,8 @@ const GeocodingSearch = forwardRef<GeocodingSearchHandle, GeocodingSearchProps>(
345349 autoFocus = { autoFocus }
346350 placeholder = { placeholder }
347351 aria-autocomplete = "list"
348- aria-controls = { listId }
349- aria-expanded = { showResults }
352+ aria-controls = { hasVisibleListbox ? listId : undefined }
353+ aria-expanded = { hasVisibleListbox }
350354 aria-label = { ariaLabel }
351355 aria-labelledby = { ariaLabelledBy }
352356 aria-invalid = { ariaInvalid }
@@ -389,7 +393,7 @@ const GeocodingSearch = forwardRef<GeocodingSearchHandle, GeocodingSearchProps>(
389393 </ StatusMessage >
390394 ) : null }
391395
392- { showResults && features . length > 0 ? (
396+ { hasVisibleListbox ? (
393397 < ResultsPanel $variant = { variant } >
394398 < ResultList id = { listId } role = "listbox" >
395399 { features . map ( ( feature , index ) => (
0 commit comments