From c819b3f409b07618aad5e9cbf3c5fef8bf615737 Mon Sep 17 00:00:00 2001 From: schmelczerandras Date: Thu, 26 Nov 2020 22:55:02 +0100 Subject: [PATCH] Fix non-woking fragment on long page load --- src/index.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/index.ts b/src/index.ts index e0e45c0..5066f6a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -24,7 +24,16 @@ const removeUnnecessaryOutlines = () => (document.activeElement as HTMLElement).blur?.() ); +// it might be necessary when the page takes too long to load +const scrollToFragment = () => { + if (location.hash) { + document.getElementById(location.hash.slice(1))?.scrollIntoView(); + } +}; + addSupportForTabNavigation(); removeUnnecessaryOutlines(); create(); + +scrollToFragment();