Auto-scroll to the opened category
Signed-off-by: gearnode <bryan@frimin.fr>
This commit is contained in:
@@ -137,6 +137,19 @@ function MitigationListContent({
|
|||||||
return initialHashCategory ? [initialHashCategory] : [];
|
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)
|
// Listen for hash changes (like when using back button)
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const handleHashChange = () => {
|
const handleHashChange = () => {
|
||||||
@@ -468,6 +481,7 @@ function MitigationListContent({
|
|||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
key={category.id}
|
key={category.id}
|
||||||
|
id={category.id}
|
||||||
className="border rounded-lg overflow-hidden"
|
className="border rounded-lg overflow-hidden"
|
||||||
>
|
>
|
||||||
<Card className="border-0 shadow-none">
|
<Card className="border-0 shadow-none">
|
||||||
|
|||||||
Reference in New Issue
Block a user