diff --git a/src/app/WardrobePage/ItemsAndSearchPanels.js b/src/app/WardrobePage/ItemsAndSearchPanels.js index b6f119d..d869a00 100644 --- a/src/app/WardrobePage/ItemsAndSearchPanels.js +++ b/src/app/WardrobePage/ItemsAndSearchPanels.js @@ -4,7 +4,6 @@ import { Box, Flex } from "@chakra-ui/core"; import ItemsPanel from "./ItemsPanel"; import SearchToolbar from "./SearchToolbar"; import SearchPanel from "./SearchPanel"; -import { isNullableType } from "graphql"; const emptyQuery = { value: "", filterToZoneLabel: null }; @@ -39,7 +38,7 @@ function ItemsAndSearchPanels({ loading, outfitState, dispatchToOutfit }) { query={searchQuery} searchQueryRef={searchQueryRef} firstSearchResultRef={firstSearchResultRef} - onChange={setSearchQuery} + onChange={onChange} /> {searchQuery.value || searchQuery.filterToZoneLabel ? ( @@ -50,7 +49,7 @@ function ItemsAndSearchPanels({ loading, outfitState, dispatchToOutfit }) { overflow="auto" ref={scrollContainerRef} > - + - + - Searching for "{query}" ( - {zoneLabel} + + {zoneLabel} + ), + [suggestionBgColor, highlightedBgColor] + ); + + const renderSuggestionsContainer = React.useCallback( + ({ containerProps, children }) => { + const { className, ...otherContainerProps } = containerProps; + return ( + + {children} + + ); + }, [] ); + // When we change the filter zone, clear out the suggestions. + React.useEffect(() => { + setSuggestions([]); + }, [query.filterToZoneLabel]); + const focusBorderColor = useColorModeValue("green.600", "green.400"); return ( @@ -83,7 +125,9 @@ function SearchToolbar({ }} getSuggestionValue={(zl) => zl} shouldRenderSuggestions={() => query.filterToZoneLabel == null} + highlightFirstSuggestion={true} renderSuggestion={renderSuggestion} + renderSuggestionsContainer={renderSuggestionsContainer} renderInputComponent={(props) => ( {query.filterToZoneLabel ? ( @@ -97,7 +141,7 @@ function SearchToolbar({ )} - {query && ( + {(query.value || query.filterToZoneLabel) && ( } @@ -123,6 +167,7 @@ function SearchToolbar({ value: query.value || "", ref: searchQueryRef, minWidth: 0, + borderBottomRadius: suggestions.length > 0 ? "0" : "md", // HACK: Chakra isn't noticing the InputLeftElement swapping out // for the InputLeftAddon, so the styles aren't updating... // Hard override!