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

[Fixes #946] Move focus to datepicker when SingleDatePicker is set to readOnly #961

Merged
merged 2 commits into from
Apr 12, 2018

Conversation

aporlando
Copy link
Contributor

Issue #946 proposes that when SingleDatePicker is set to readOnly, then its onFocus behavior should move the focus to the datepicker from the input (since there's no opportunity to type in a readOnly input).
This helps accomplish behavior to hook into subsequent clicks on a readOnly input to close the datepicker (on non-touch enabled devices).
Note that this is a separate issue from #958 which provides a hook to keep focus on the input.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 86.329% when pulling 999ba3b on aporlando:onFocusReadOnly into 05b17b0 on airbnb:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 86.329% when pulling 999ba3b on aporlando:onFocusReadOnly into 05b17b0 on airbnb:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 86.329% when pulling 66d01ed on aporlando:onFocusReadOnly into 05b17b0 on airbnb:master.

@majapw
Copy link
Collaborator

majapw commented Jan 19, 2018

Does this actually end up closing the datepicker when you click on the input again?

@aporlando
Copy link
Contributor Author

aporlando commented Jan 19, 2018

No. It allows you to accomplish it in the onFocusChange event for readOnly inputs. Something like:

<SingleDatePicker readOnly
focused={this.state.focused}
onFocusChange={({ focused }) => {
  if (this.state.focused && focused) {
      // Already focused, so datepicker is open, focus event again means subsequent input interaction
      this.setState({ focused: false });
  }
  else {
      this.setState({focused});
  }
}}
/>

@coveralls
Copy link

coveralls commented Jan 19, 2018

Coverage Status

Coverage remained the same at 84.85% when pulling 5169d47 on aporlando:onFocusReadOnly into 547e06f on airbnb:master.

@majapw majapw force-pushed the onFocusReadOnly branch 2 times, most recently from 5c17a2f to 9ea2c5b Compare April 12, 2018 18:31
@majapw majapw merged commit 536110b into react-dates:master Apr 12, 2018
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

Successfully merging this pull request may close these issues.

None yet

4 participants