Accordion - Change scrollRestoration delay to 1sec

This commit is contained in:
2020-10-26 17:14:41 +05:30
parent 0f24e566be
commit 5a8cbef517
+7 -3
View File
@@ -28,9 +28,13 @@ const Accordion = ({ children, title = "More" }) => {
// 4. and scroll into view and focus // 4. and scroll into view and focus
targetElement.focus(); targetElement.focus();
targetElement.scrollIntoView({ block: "center" }); targetElement.scrollIntoView({ block: "center" });
if ("scrollRestoration" in history) { // Increased for mobile browsers
history.scrollRestoration = "auto"; const scrollRestorationDelay = 1000; // 1s
} setTimeout(() => {
if ("scrollRestoration" in history) {
history.scrollRestoration = "auto";
}
}, scrollRestorationDelay);
} }
} }