From a16ffbc1f4ee818e2b46707caec7c65827644183 Mon Sep 17 00:00:00 2001 From: gearnode Date: Tue, 8 Apr 2025 07:57:52 -0700 Subject: [PATCH] Auto-scroll to the opened category Signed-off-by: gearnode --- .../mitigations/MitigationListView.tsx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/apps/console/src/pages/organizations/mitigations/MitigationListView.tsx b/apps/console/src/pages/organizations/mitigations/MitigationListView.tsx index 3ffb8d857..ced6cde4d 100644 --- a/apps/console/src/pages/organizations/mitigations/MitigationListView.tsx +++ b/apps/console/src/pages/organizations/mitigations/MitigationListView.tsx @@ -137,6 +137,19 @@ function MitigationListContent({ return initialHashCategory ? [initialHashCategory] : []; }); + // Scroll to expanded category when page loads with a category in the fragment + useEffect(() => { + if (initialHashCategory) { + // Small delay to ensure the DOM is fully rendered + setTimeout(() => { + const element = document.getElementById(initialHashCategory); + if (element) { + element.scrollIntoView({ behavior: "smooth", block: "start" }); + } + }, 100); + } + }, [initialHashCategory]); + // Listen for hash changes (like when using back button) useEffect(() => { const handleHashChange = () => { @@ -468,6 +481,7 @@ function MitigationListContent({ return (