From f78c1872a075da41ef932d6e952b963235f3c5e3 Mon Sep 17 00:00:00 2001 From: Florian Sommariva <1926041+dtrucs@users.noreply.github.com> Date: Wed, 9 Oct 2024 10:25:10 +0200 Subject: [PATCH 1/7] Remove scrollRestoration to top from trek detail page --- frontend/src/pages/trek/[slug].tsx | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/frontend/src/pages/trek/[slug].tsx b/frontend/src/pages/trek/[slug].tsx index 4ee37dc52..f4557ae8b 100644 --- a/frontend/src/pages/trek/[slug].tsx +++ b/frontend/src/pages/trek/[slug].tsx @@ -1,7 +1,6 @@ import { GetServerSideProps, NextPage } from 'next'; import router, { useRouter } from 'next/router'; import { DetailsUI } from 'components/pages/details'; -import { useEffect } from 'react'; import { dehydrate, QueryCache, QueryClient } from '@tanstack/react-query'; import { getDetails, getTrekFamily } from 'modules/details/connector'; import { isUrlString } from 'modules/utils/string'; @@ -34,7 +33,10 @@ export const getServerSideProps: GetServerSideProps = async context => { queryFn: () => getCommonDictionaries(locale), }); - await queryClient.prefetchQuery({ queryKey: ['details', id, locale], queryFn: () => getDetails(id, locale, commonDictionaries) }); + await queryClient.prefetchQuery({ + queryKey: ['details', id, locale], + queryFn: () => getDetails(id, locale, commonDictionaries), + }); const details = queryClient.getQueryData
(['details', id, locale]); @@ -44,7 +46,6 @@ export const getServerSideProps: GetServerSideProps = async context => { }); if (details !== undefined) { - const redirect = redirectIfWrongUrl( id, details.title, @@ -54,9 +55,9 @@ export const getServerSideProps: GetServerSideProps = async context => { ); if (redirect) return { - redirect, - }; - } + redirect, + }; + } return { props: { @@ -81,11 +82,6 @@ const Trek: NextPage = ({ errorCode }) => { const { slug, parentId } = query; const language = locale ?? getDefaultLanguage(); - useEffect(() => { - // Force to scroll top on page refresh - window.history.scrollRestoration = 'manual'; - }, []); - if (errorCode === 404) return ; return ; From e4f785b5836774d8097d05ddc021bae72abb7e7b Mon Sep 17 00:00:00 2001 From: Florian Sommariva <1926041+dtrucs@users.noreply.github.com> Date: Wed, 9 Oct 2024 10:32:11 +0200 Subject: [PATCH 2/7] Active nextconfig scrollRestoration feature --- frontend/next.config.js | 1 + 1 file changed, 1 insertion(+) diff --git a/frontend/next.config.js b/frontend/next.config.js index b054c39b8..43634f9b3 100644 --- a/frontend/next.config.js +++ b/frontend/next.config.js @@ -69,6 +69,7 @@ const nextConfig = { }, experimental: { instrumentationHook: true, + scrollRestoration: true, }, }; From a61d69f4261d58a620ed7d1954d187e235448fba Mon Sep 17 00:00:00 2001 From: Florian Sommariva <1926041+dtrucs@users.noreply.github.com> Date: Wed, 9 Oct 2024 10:46:26 +0200 Subject: [PATCH 3/7] Simplify CSS for search positions element --- frontend/src/components/Header/Header.tsx | 17 ++--------------- frontend/src/components/pages/search/Search.tsx | 12 +++--------- .../search/components/FilterBar/FilterField.tsx | 2 +- .../pages/search/components/FilterBar/index.tsx | 2 +- 4 files changed, 7 insertions(+), 26 deletions(-) diff --git a/frontend/src/components/Header/Header.tsx b/frontend/src/components/Header/Header.tsx index 9cf67ebc1..0bf049306 100644 --- a/frontend/src/components/Header/Header.tsx +++ b/frontend/src/components/Header/Header.tsx @@ -3,7 +3,6 @@ import { FormattedMessage } from 'react-intl'; import { routes } from 'services/routes'; import { Link } from 'components/Link'; -import { Display } from 'hooks/useHideOnScrollDown'; import InlineMenu from 'components/InlineMenu'; import { GoToSearchButton } from 'components/GoToSearchButton'; @@ -15,11 +14,6 @@ import { useHeader } from './useHeader'; export const Header: React.FC = () => { const menuNode = useRef(null); const { config, menuItems, isDesktopMenu, intl } = useHeader(menuNode); - /** - * Disabled for now to handle the map on the search page - */ - // const headerState = useHideOnScrollDown(sizes.desktopHeader); - const headerState: Display = 'DISPLAYED'; const headerTop = config.headerTopHtml[intl.locale] ?? config.headerTopHtml.default; const headerBottom = config.headerBottomHtml[intl.locale] ?? config.headerBottomHtml.default; @@ -31,14 +25,7 @@ export const Header: React.FC = () => { )} -