From acd1c732976a675c2127f818b3c11d0ffa3fbb05 Mon Sep 17 00:00:00 2001 From: Ankit Dash Date: Sun, 17 Mar 2024 03:30:54 +0530 Subject: [PATCH 1/2] navigate user to respective categories on entering the URL --- components/tools/ToolDashboard.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/components/tools/ToolDashboard.js b/components/tools/ToolDashboard.js index 5d93d55b188b..a6cc70551492 100644 --- a/components/tools/ToolDashboard.js +++ b/components/tools/ToolDashboard.js @@ -61,6 +61,22 @@ export default function ToolDashboard() { }; }); + // Navigates the user to the specific categories on providing the URL + useEffect(() => { + if (!loading) { + const urlPath = router.asPath; + const elementIndex = urlPath.lastIndexOf('#'); + if (elementIndex !== -1) { + const element = urlPath.substring(elementIndex + 1).replace(/%20/g, ' '); + const DOMElement = document.getElementById(element); + if (DOMElement) { + DOMElement.scrollIntoView({ behavior: 'smooth', block: 'start', inline: 'nearest' }); + } + } + } + }, [loading]); + + // Function to update the list of tools according to the current filters applied const updateToolsList = () => { let tempToolsList = {}; From 4cb3343a7f4c20e858f85f3bd0a405d033ae9380 Mon Sep 17 00:00:00 2001 From: Ankit Dash Date: Sun, 17 Mar 2024 04:07:02 +0530 Subject: [PATCH 2/2] scroll to heading --- components/tools/ToolsList.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/tools/ToolsList.js b/components/tools/ToolsList.js index 048c7acc2c32..c2ee79d7b12a 100644 --- a/components/tools/ToolsList.js +++ b/components/tools/ToolsList.js @@ -6,7 +6,7 @@ export default function toolsList({ toolsData }) {
{Object.keys(toolsData).map((categoryName, index) => { if(toolsData[categoryName].toolsList.length > 0) return ( -
+
{categoryName}