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

Improve keyboard navigation for date range selection #1499

Merged
merged 26 commits into from
Jan 23, 2019

Conversation

monokrome
Copy link
Contributor

These changes represent an effort to improve the navigation of the date range selection via keyboard. This is primarily modifying the position of the DayPicker so that it is after the currently focused input on the date ranges, and comes with a few small changes to keep reasonable usability for keyboard navigation inside of the DayPicker.

@monokrome
Copy link
Contributor Author

@majapw Although not ready for review yet, I'm creating this PR as requested so that you can see the current code 😺

@coveralls
Copy link

coveralls commented Jan 3, 2019

Coverage Status

Coverage decreased (-0.2%) to 84.968% when pulling e137cea on tkjr-calendar-tabbing into d572bea on master.

.gitignore Outdated Show resolved Hide resolved
src/components/DateRangePicker.jsx Outdated Show resolved Hide resolved
src/components/DateRangePickerInput.jsx Outdated Show resolved Hide resolved
src/components/SingleDatePicker.jsx Outdated Show resolved Hide resolved
src/components/SingleDatePicker.jsx Outdated Show resolved Hide resolved
src/components/SingleDatePickerInput.jsx Show resolved Hide resolved
src/components/DateRangePickerInput.jsx Show resolved Hide resolved
Copy link
Collaborator

@majapw majapw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yay, nice test coverage! I think overall we'd prefer to use the onTab/onShiftTab callbacks in the DayPicker as the solution for this rather than add this blur handler. In addition, I think the props already exist on the DateRangePickerInput(Controller) that let you know where to put the calendar.

.gitignore Outdated Show resolved Hide resolved
src/components/DateRangePicker.jsx Outdated Show resolved Hide resolved
src/components/DateRangePickerInput.jsx Show resolved Hide resolved
src/components/DateRangePickerInput.jsx Outdated Show resolved Hide resolved
src/components/DateRangePickerInput.jsx Outdated Show resolved Hide resolved
src/components/DateRangePickerInput.jsx Outdated Show resolved Hide resolved
src/components/DateRangePickerInputController.jsx Outdated Show resolved Hide resolved
src/components/SingleDatePicker.jsx Outdated Show resolved Hide resolved
@monokrome
Copy link
Contributor Author

Oops! Need to write test! Will do so tonight :D

Copy link
Collaborator

@majapw majapw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit confused about the comments about the children prop! Maybe we can talk through it tomorrow.

Other than that, it's looking great!

src/components/DateRangePicker.jsx Outdated Show resolved Hide resolved
src/components/DateRangePicker.jsx Show resolved Hide resolved
src/components/DateRangePicker.jsx Show resolved Hide resolved
src/components/DateRangePickerInput.jsx Show resolved Hide resolved
src/components/SingleDatePicker.jsx Show resolved Hide resolved
@majapw
Copy link
Collaborator

majapw commented Jan 10, 2019

Hey @monokrome, would be good to get a status update on this tomorrow! I'd like to do a release for @nkinser's change and I'd love to get this in too if it's close.

@monokrome
Copy link
Contributor Author

Discussed a bit with @majapw, but I want to document why we are using focusoutinstead of tab for anyone else following.

I spent a bit of time trying to find a way to do this with onblur/onfocus/onkeydown, but the event doesn't give us the information that we need. Tabbing out sets document.activeElement to the body element when the next item isn't a form element (possibly in that case as well).

In order to ensure that we are staying safe, I have implemented this using the focusout event on an element ref until facebook/react#6410 is released, at which time we can consider using FocusOut natively. 😺

@monokrome monokrome force-pushed the tkjr-calendar-tabbing branch 3 times, most recently from e9fb582 to a68d154 Compare January 11, 2019 20:40
Copy link
Collaborator

@majapw majapw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One major comment (about the children && children line). Everything else looks good!

src/components/DateRangePicker.jsx Show resolved Hide resolved
src/components/DateRangePickerInput.jsx Show resolved Hide resolved
src/components/DayPickerRangeController.jsx Outdated Show resolved Hide resolved
src/components/SingleDatePickerInputController.jsx Outdated Show resolved Hide resolved
@majapw
Copy link
Collaborator

majapw commented Jan 16, 2019

Any update on this?

Bailey Stoner added 2 commits January 22, 2019 15:06
I'm worried that maybe this feels a bit redundant since anything in
`this.state` should be "current", but it does help to solve the issue w/
naming being weird?...
@monokrome
Copy link
Contributor Author

@majapw I think this is ready for review now. All changes mentioned have been made, with the caveat that I switched the naming for the currentDateOffset to renaming the local variable to nextDateOffset to retain dateOffset in state. Happy to change that, but this feels like a smaller change and the name current in state felt a bit redundant 😺

Copy link
Collaborator

@majapw majapw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming everything has been smoke-tested thoroughly in storybook, this looks great! I just have one comment where I think this.state.nextDateOffset was accidentally used instead of dateOffset

src/components/DayPickerRangeController.jsx Outdated Show resolved Hide resolved
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

5 participants