Skip to content

Commit

Permalink
Handle crashing of .scrollIntoView on Firefox 52-57 (#1393)
Browse files Browse the repository at this point in the history
* Handle crashing of .scrollIntoView on Firefox 52-57

* Still call scrollIntoView if throws exception with parameters
  • Loading branch information
dmtrKovalenko authored Nov 15, 2019
1 parent 053c069 commit 66074f3
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions lib/src/views/Year/YearView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,15 @@ export const YearSelection: React.FC<YearSelectionProps> = ({

React.useEffect(() => {
if (selectedYearRef.current && selectedYearRef.current.scrollIntoView) {
selectedYearRef.current.scrollIntoView({
block: currentVariant === 'static' ? 'nearest' : 'center',
behavior: animateYearScrolling ? 'smooth' : 'auto',
});
try {
selectedYearRef.current.scrollIntoView({
block: currentVariant === 'static' ? 'nearest' : 'center',
behavior: animateYearScrolling ? 'smooth' : 'auto',
});
} catch (e) {
// call without arguments in case when scrollIntoView works improperly (e.g. Firefox 52-57)
selectedYearRef.current.scrollIntoView();
}
}
}, []); // eslint-disable-line

Expand Down

0 comments on commit 66074f3

Please sign in to comment.