Commit f29bb521 authored by Stefan Probst's avatar Stefan Probst
Browse files

fix: fix scroll position on search facet change

parent 274c749f
Pipeline #150949 passed with stages
in 91 minutes and 23 seconds
......@@ -48,6 +48,7 @@ const SearchFacets = ({
request,
searchParams,
itemCategories,
focusRef,
}) => {
const { categories, facets, query, sort } = searchParams
const { info } = request || {}
......@@ -80,6 +81,10 @@ const SearchFacets = ({
query,
sort,
})
if (focusRef && focusRef.current) {
focusRef.current.scrollIntoView()
}
}
const handleFacetChange = event => {
......@@ -106,6 +111,10 @@ const SearchFacets = ({
query,
sort,
})
if (focusRef && focusRef.current) {
focusRef.current.scrollIntoView()
}
}
return (
......
......@@ -10,7 +10,11 @@ import { fetchSearchResults } from '../../store/actions/items'
import { fetchItemCategories } from '../../store/actions/itemCategories'
import { selectors } from '../../store/reducers'
const SearchScreenContainer = ({ onSearchParamsChange, searchParams }) => {
const SearchScreenContainer = ({
onSearchParamsChange,
searchParams,
focusRef,
}) => {
const dispatch = useDispatch()
const { categories, facets, page, query, sort } = searchParams
......@@ -74,6 +78,7 @@ const SearchScreenContainer = ({ onSearchParamsChange, searchParams }) => {
results={results}
searchParams={searchParams}
itemCategories={itemCategories}
focusRef={focusRef}
/>
)
}
......@@ -97,6 +102,7 @@ export const SearchScreen = ({
results,
searchParams,
itemCategories,
focusRef,
}) => (
<>
<Heading variant="h1" css={css({ mt: 4 })}>
......@@ -111,6 +117,7 @@ export const SearchScreen = ({
request={request}
searchParams={searchParams}
itemCategories={itemCategories}
focusRef={focusRef}
/>
</Sidebar>
<SearchResults
......
......@@ -34,6 +34,7 @@ const SearchPage = () => {
<SearchScreen
onSearchParamsChange={setSearchParams}
searchParams={searchParams}
focusRef={focusRef}
/>
</Screen>
</Main>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment