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

[Safari][RangeCalendar] Date input switch does not work as expected #644

Open
BionBit opened this issue Dec 2, 2019 · 0 comments
Open

Comments

@BionBit
Copy link

BionBit commented Dec 2, 2019

STR:

  1. Click on the start date input
  2. Click on the end date input
  3. 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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant