From f9dcb4d6f69b9ccb9984ceaaf724963ca8e6cf56 Mon Sep 17 00:00:00 2001 From: samwisekind Date: Sun, 27 Oct 2024 12:38:24 +0000 Subject: [PATCH 1/2] Retain catalogue index state on navigation --- next.config.js | 3 ++ src/components/Filters/Filters.tsx | 8 +++- .../catalogues/bottlenose-dolphin/[slug].tsx | 2 +- src/pages/research/catalogues/index.tsx | 45 +++++++++++++++++-- .../catalogues/minke-whale/[slug].tsx | 2 +- 5 files changed, 53 insertions(+), 7 deletions(-) diff --git a/next.config.js b/next.config.js index efb3380..13e1b20 100644 --- a/next.config.js +++ b/next.config.js @@ -7,6 +7,9 @@ const redirects = require('./redirects.json'); const nextConfig = { reactStrictMode: true, poweredByHeader: false, + experimental: { + scrollRestoration: true + }, images: { remotePatterns: [{ protocol: 'https', diff --git a/src/components/Filters/Filters.tsx b/src/components/Filters/Filters.tsx index 1825cb2..a8d2cf3 100644 --- a/src/components/Filters/Filters.tsx +++ b/src/components/Filters/Filters.tsx @@ -3,11 +3,13 @@ import styles from './Filters.module.scss'; interface UseSearchProps { callback: Function, label?: string, + defaultValue?: string, } const UseSearch = ({ callback, label = 'Search...', + defaultValue, }: UseSearchProps) => ( callback((target as HTMLInputElement).value)} placeholder={label} className={styles.search} + defaultValue={defaultValue} autoComplete="off" /> ); interface DropdownProps { name: string, + defaultValue?: string, options: Array<{ text: string, value: string, @@ -30,11 +34,13 @@ interface DropdownProps { const UseDropdown = ({ name, + defaultValue, options, callback, }: DropdownProps) => (