diff --git a/components/tools/ToolsList.js b/components/tools/ToolsList.js index 048c7acc2c32..e810019f61df 100644 --- a/components/tools/ToolsList.js +++ b/components/tools/ToolsList.js @@ -1,12 +1,27 @@ import ToolsCard from './ToolsCard'; import Heading from '../typography/Heading' +import { useRef, useEffect } from 'react'; import Paragraph from '../typography/Paragraph' export default function toolsList({ toolsData }) { + const categoryRefs = useRef({}); + +// Below UseEffect scrolls the page to a specific category referenced in the URL hash. + useEffect(() => { + const hash = window.location.hash; + if (hash) { + const decodedHash = decodeURIComponent(hash.slice(1)); + const categoryRef = categoryRefs.current[decodedHash]; + if (categoryRef) { + categoryRef.scrollIntoView({ behavior: 'smooth', block: 'start'}); + } + } + },[]); + return ( -