Accordion - Change scrollRestoration delay to 1sec

This commit is contained in:
2020-10-26 17:14:41 +05:30
parent 0f24e566be
commit 5a8cbef517
+4
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" });
// Increased for mobile browsers
const scrollRestorationDelay = 1000; // 1s
setTimeout(() => {
if ("scrollRestoration" in history) { if ("scrollRestoration" in history) {
history.scrollRestoration = "auto"; history.scrollRestoration = "auto";
} }
}, scrollRestorationDelay);
} }
} }