Skip to content

Commit

Permalink
feat(sanity): do not fade out global search results while fetching more
Browse files Browse the repository at this point in the history
Search results now only fade out when input parameters change,
reflecting that the results that have already been loaded no longer
match the input parameters.

They no longer fade out when fetching more results for the same set of
input parameters.
  • Loading branch information
juice49 committed Dec 10, 2024
1 parent e8bad21 commit a303002
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import {type ItemSelectHandler, SearchResultItem} from './item/SearchResultItem'
const VIRTUAL_LIST_SEARCH_RESULT_ITEM_HEIGHT = 57 // px
const VIRTUAL_LIST_OVERSCAN = 4

const SearchResultsInnerFlex = styled(Flex)<{$loading: boolean}>`
opacity: ${({$loading}) => ($loading ? 0.5 : 1)};
const SearchResultsInnerFlex = styled(Flex)<{$loadingFirstPage: boolean}>`
opacity: ${({$loadingFirstPage}) => ($loadingFirstPage ? 0.5 : 1)};
overflow-x: hidden;
overflow-y: auto;
position: relative;
Expand All @@ -37,7 +37,7 @@ export function SearchResults({disableIntentLink, inputElement, onItemSelect}: S
dispatch,
onClose,
setSearchCommandList,
state: {debug, filters, fullscreen, lastActiveIndex, result, terms},
state: {debug, filters, fullscreen, lastActiveIndex, result, terms, cursor},
} = useSearchState()
const {t} = useTranslation()
const recentSearchesStore = useRecentSearchesStore()
Expand Down Expand Up @@ -90,7 +90,11 @@ export function SearchResults({disableIntentLink, inputElement, onItemSelect}: S
{hasSearchResults && <SortMenu />}

{/* Results */}
<SearchResultsInnerFlex $loading={result.loading} aria-busy={result.loading} flex={1}>
<SearchResultsInnerFlex
$loadingFirstPage={result.loading && cursor === null}
aria-busy={result.loading}
flex={1}
>
{hasError ? (
<SearchError />
) : (
Expand Down

0 comments on commit a303002

Please sign in to comment.