Skip to content

Commit

Permalink
report(flow): remove smooth scrolling (#13317)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamraine authored Nov 11, 2021
1 parent 9d293da commit 99bd2fa
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions flow-report/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,22 @@ import {Topbar} from './topbar';
import {Header} from './header';
import {I18nProvider} from './i18n/i18n';

function getAnchorElement(hashState: LH.FlowResult.HashState|null) {
if (!hashState || !hashState.anchor) return null;
return document.getElementById(hashState.anchor);
}

const Content: FunctionComponent = () => {
const hashState = useHashState();
const ref = useRef<HTMLDivElement>(null);

useLayoutEffect(() => {
if (hashState && hashState.anchor) {
const el = document.getElementById(hashState.anchor);
if (el) {
el.scrollIntoView({behavior: 'smooth'});
return;
}
const el = getAnchorElement(hashState);
if (el) {
el.scrollIntoView();
} else if (ref.current) {
ref.current.scrollTop = 0;
}

// Scroll to top no anchor is found.
if (ref.current) ref.current.scrollTop = 0;
}, [hashState]);

return (
Expand Down

0 comments on commit 99bd2fa

Please sign in to comment.