Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle crashing of .scrollIntoView on Firefox 52-57 #1393

Merged
merged 2 commits into from
Nov 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 21 additions & 17 deletions docs/prop-types.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
},
"showTodayButton": {
"defaultValue": {
"value": "false"
"value": false
},
"description": "If true today button will be displayed <b>Note*</b> that clear button has higher priority",
"name": "showTodayButton",
Expand All @@ -77,7 +77,7 @@
},
"clearable": {
"defaultValue": {
"value": "false"
"value": false
},
"description": "Show clear action in picker dialog",
"name": "clearable",
Expand Down Expand Up @@ -391,7 +391,7 @@
},
"required": false,
"type": {
"name": "FunctionComponent<ToolbarComponentProps> | ComponentClass<ToolbarComponentProps, any>"
"name": "ComponentClass<ToolbarComponentProps, any> | FunctionComponent<ToolbarComponentProps>"
}
},
"variant": {
Expand Down Expand Up @@ -1012,7 +1012,7 @@
},
"required": false,
"type": {
"name": "FunctionComponent<ToolbarComponentProps> | ComponentClass<ToolbarComponentProps, any>"
"name": "ComponentClass<ToolbarComponentProps, any> | FunctionComponent<ToolbarComponentProps>"
}
},
"PopoverProps": {
Expand Down Expand Up @@ -1685,7 +1685,7 @@
},
"required": false,
"type": {
"name": "FunctionComponent<ToolbarComponentProps> | ComponentClass<ToolbarComponentProps, any>"
"name": "ComponentClass<ToolbarComponentProps, any> | FunctionComponent<ToolbarComponentProps>"
}
},
"variant": {
Expand Down Expand Up @@ -2114,7 +2114,7 @@
},
"required": false,
"type": {
"name": "FunctionComponent<ToolbarComponentProps> | ComponentClass<ToolbarComponentProps, any>"
"name": "ComponentClass<ToolbarComponentProps, any> | FunctionComponent<ToolbarComponentProps>"
}
},
"PopoverProps": {
Expand Down Expand Up @@ -2595,7 +2595,7 @@
},
"required": false,
"type": {
"name": "FunctionComponent<ToolbarComponentProps> | ComponentClass<ToolbarComponentProps, any>"
"name": "ComponentClass<ToolbarComponentProps, any> | FunctionComponent<ToolbarComponentProps>"
}
},
"variant": {
Expand Down Expand Up @@ -3285,7 +3285,7 @@
},
"required": false,
"type": {
"name": "FunctionComponent<ToolbarComponentProps> | ComponentClass<ToolbarComponentProps, any>"
"name": "ComponentClass<ToolbarComponentProps, any> | FunctionComponent<ToolbarComponentProps>"
}
},
"PopoverProps": {
Expand Down Expand Up @@ -3768,7 +3768,9 @@
}
},
"minDate": {
"defaultValue": null,
"defaultValue": {
"value": null
},
"description": "Min date",
"name": "minDate",
"parent": {
Expand All @@ -3781,7 +3783,9 @@
}
},
"maxDate": {
"defaultValue": null,
"defaultValue": {
"value": null
},
"description": "Max date",
"name": "maxDate",
"parent": {
Expand All @@ -3795,7 +3799,7 @@
},
"disablePast": {
"defaultValue": {
"value": "false"
"value": false
},
"description": "Disable past dates",
"name": "disablePast",
Expand All @@ -3810,7 +3814,7 @@
},
"disableFuture": {
"defaultValue": {
"value": "false"
"value": false
},
"description": "Disable future dates",
"name": "disableFuture",
Expand Down Expand Up @@ -3864,7 +3868,7 @@
},
"allowKeyboardControl": {
"defaultValue": {
"value": "true"
"value": true
},
"description": "Enables keyboard listener for moving between days in calendar",
"name": "allowKeyboardControl",
Expand Down Expand Up @@ -3972,7 +3976,7 @@
},
"ampm": {
"defaultValue": {
"value": "true"
"value": true
},
"description": "12h/24h clock mode",
"name": "ampm",
Expand All @@ -3987,7 +3991,7 @@
},
"minutesStep": {
"defaultValue": {
"value": "1"
"value": 1
},
"description": "Minutes step",
"name": "minutesStep",
Expand Down Expand Up @@ -4069,7 +4073,7 @@
},
"ampm": {
"defaultValue": {
"value": "true"
"value": true
},
"description": "12h/24h clock mode",
"name": "ampm",
Expand All @@ -4084,7 +4088,7 @@
},
"minutesStep": {
"defaultValue": {
"value": "1"
"value": 1
},
"description": "Minutes step",
"name": "minutesStep",
Expand Down
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