calendar
calendar copied to clipboard
[Safari][RangeCalendar] Date input switch does not work as expected
STR:
- Click on the start date input
- Click on the end date input
- Notice that you cannot focus back again on the start input
Behavior can be observed here, https://react-component.github.io/calendar/examples/antd-range-calendar.html
Proposed fix - disable setSelectionRange on safari (tested locally),
+ const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
...
componentDidUpdate() {
- if (dateInputInstance && this.state.hasFocus && !this.state.invalid &&
- !(cachedSelectionStart === 0 && cachedSelectionEnd === 0)) {
- dateInputInstance.setSelectionRange(cachedSelectionStart, cachedSelectionEnd);
+ if (!isSafari) { // Exclude safari, since it has a bug with setSelectionRange
+ if (dateInputInstance && this.state.hasFocus && !this.state.invalid &&
+ !(cachedSelectionStart === 0 && cachedSelectionEnd === 0)) {
+ dateInputInstance.setSelectionRange(cachedSelectionStart, cachedSelectionEnd);
+ }
}
}
Question - Do we even need setSelectionRange? Does anyone use it?