Skip to content

Commit

Permalink
Bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
sherakama committed Oct 28, 2024
1 parent 2f47970 commit 4dd8280
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/components/page-types/searchPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const SearchPage = (props) => {
stalledSearchDelay={2000}
routing={routing}
future={{
preserveSharedStateOnUnmount: true,
preserveSharedStateOnUnmount: false,
}}
insights
>
Expand Down
2 changes: 1 addition & 1 deletion src/components/search/SearchFacet.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const SearchFacet = ({ className, attribute, label, excludes = [] }) => {

{filteredItems.map((option, index) => (
<label
key={slugify(option.value)}
key={`attriute-${slugify(option.value)}`}
className={`su-label su-flex su-items-center su-cursor-pointer su-text-19 hover:su-text-digital-red-xlight
${index ? 'su-mt-20' : ''}`}
>
Expand Down
17 changes: 12 additions & 5 deletions src/components/search/SearchPageContent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
ClearRefinements,
} from 'react-instantsearch';
import SbEditable from 'storyblok-react';
import { dcnb } from 'cnbuilder';
import { cnb, dcnb } from 'cnbuilder';
import Icon from 'react-hero-icon';
import { Container } from '../layout/Container';
import Layout from '../partials/Layout';
Expand Down Expand Up @@ -34,7 +34,7 @@ import useDisplay from '../../hooks/useDisplay';
const SearchPageContent = (props) => {
const { blok } = props;
const { nbHits, areHitsSorted, nbSortedHits } = useStats();
const { status } = useInstantSearch();
const { status, started } = useInstantSearch();
const [opened, setOpened] = useState(false);
const { refine: clearFilters } = useClearRefinements();
const { showDesktop, showMobile } = useDisplay();
Expand All @@ -49,6 +49,10 @@ const SearchPageContent = (props) => {
return nbHits;
}, [areHitsSorted, nbHits, nbSortedHits]);

const isLoading = status === 'loading' && started;
const isIdle = status === 'idle' && started;
const hasNoResults = resultCount === 0 && isIdle && started;

return (
<SbEditable content={blok}>
<Layout hasHero={false} {...props} blok={blok}>
Expand All @@ -75,7 +79,10 @@ const SearchPageContent = (props) => {
resultCount > 0 ? 'lg:su-col-start-4' : 'lg:su-col-start-3'
}
>
<SearchField emptySearchMessage={blok.emptySearchMessage} />
<SearchField
emptySearchMessage={blok.emptySearchMessage}
className={cnb({ 'su-opacity-30': isLoading })}
/>
</GridCell>
</Grid>

Expand Down Expand Up @@ -180,7 +187,7 @@ const SearchPageContent = (props) => {
<Grid
xs={12}
className={dcnb('filters su-rs-mt-7 lg:su-grid-gap', {
'su-hidden': !nbHits && status === 'idle',
'su-hidden': hasNoResults,
})}
>
{/* DESKTOP FILTERS */}
Expand Down Expand Up @@ -244,7 +251,7 @@ const SearchPageContent = (props) => {
</GridCell>
</Grid>

{!nbHits && status === 'idle' && (
{hasNoResults && (
<Grid xs={12} className="su-rs-mt-7">
<SearchNoResults
heading={blok.noResultsHeading}
Expand Down
2 changes: 1 addition & 1 deletion src/components/search/SearchResults.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const SearchResults = () => {
<div
id="search-results"
className={cnb({
'su-opacity-50': isLoading,
'su-opacity-30': isLoading,
})}
>
<div
Expand Down

0 comments on commit 4dd8280

Please sign in to comment.