Skip to content
This repository has been archived by the owner on Jul 12, 2024. It is now read-only.

Add Single Date Picker #1069

Merged
merged 2 commits into from
Dec 21, 2018
Merged

Conversation

psealock
Copy link
Collaborator

@psealock psealock commented Dec 12, 2018

Working towards #1027
Depends on WordPress/gutenberg#12855

screen shot 2018-12-14 at 1 37 53 pm

screen shot 2018-12-14 at 1 38 37 pm

Test

  1. Checkout psealock:add/focusOnMount-to-dropdown branch of Gutenberg or just make the two line change in Dropdown: add focusOnMount prop to pass onto Popover component WordPress/gutenberg#12855.
  2. View Calendar in DevDocs /wp-admin/admin.php?page=wc-admin#/devdocs/calendar
  3. Play around with the single date picker
    • Mobile sizes
    • Keyboard interactions
    • VoiceOver
  4. If you see a propType warning for block, the fix for that is here DateTimePicker: fix prop warning for WordPress/gutenberg#12933

Key Decisions

  • Make the react-dates datepicker unreachable by keyboard. There is no way to simultaneously keep focus on the input so keyboard users can type inputs and allow focus on the dropdown for selection via keyboard. One solution is to keep focus on the input, then allow focus on the dropdown via tabbing. I don't like this because it misrepresents the sequential flow of a form and causes confusion, for me at least. React-dates implementation chooses similar behaviour.
  • Don't allow full screen expansion of dropdown on mobile screens. Otherwise, it forces focus away from the input field, effectively removing the ability to use the keyboard.

@psealock psealock self-assigned this Dec 12, 2018
@probot-autolabeler probot-autolabeler bot added focus: components Issues for woocommerce components Packages labels Dec 12, 2018
@psealock psealock requested a review from a team December 14, 2018 01:04
@timmyc timmyc added the focus: accessibility The issue/PR is related to accessibility. label Dec 14, 2018
@timmyc timmyc requested a review from ryelle December 14, 2018 18:38
@timmyc
Copy link
Contributor

timmyc commented Dec 14, 2018

This is looking really good @psealock - so just wondering if we should consider using the WP core date picker here - apologies for not mentioning that as a suggestion on the original issue:

image

While the design is a bit different, it has passed the a11y review from core. @LevinMedia thoughts from the design side of things?

@LevinMedia
Copy link
Contributor

LevinMedia commented Dec 15, 2018

@timmyc @psealock re: the question about the core component... could we re-style so it looks more like the input we have now, and behaves like what I describe at #1097 in regards to using number input, and automatically advancing through each part of the input... while maintaining the accessibility?

@psealock
Copy link
Collaborator Author

Here is core's DatePicker with some basic Woo styling:

screen shot 2018-12-17 at 9 13 13 am

We should go in this direction. It will involve some functionality upstream pull requests (invalid days, and firstDayOfWeek support) and some stylistic changes (day sizing and box v. circle).

wc-admin's date range picker is heavily tied to its input format (single text input v. GB's multiple inputs) so we can't reuse Core's datepicker there, but we could match styles.

could we re-style so it looks more like the input we have now, and behaves like what I describe at #1097 in regards to using number input, and automatically advancing through each part of the input... while maintaining the accessibility?

I really like the suggestion by @LevinMedia in #1097. Happily, Core has separated the inputs from the picker for us, so we can deal with it separately. I think there can be some a11y gains to be made with that approach. I'll explore those thoughts further in that issue.

@LevinMedia how do you feel about the styles in the screen shot and moving towards this direction with the date-range picker for reports?

@psealock
Copy link
Collaborator Author

psealock commented Dec 17, 2018

07be925 switches to use Core's Datepicker.

Here are upstream Gutenberg changes needed to get to parity. Note that these features are not required for this PR to be merged.

  • Add firstDayOfWeek support. Grabs from moment.locale() automatically
  • Add invalidDays support.
  • Allow null date selection. Current implementation forces a selection of current day when none is provided, which means the calendar shows today as selected when mounted.

These seem to be reasonable requests and I think I'll be able to make them happen.

@psealock
Copy link
Collaborator Author

Confirmed with @LevinMedia that this is the direction we'll want to pursue. I'm going to mark this as blocked for now until the above^^^ Gutenberg issues can be resolved.

@psealock psealock added status: blocked The issue is blocked from progressing, waiting for another piece of work to be done. and removed [Status] Needs Review labels Dec 17, 2018
@psealock
Copy link
Collaborator Author

psealock commented Dec 20, 2018

@timmyc how do you feel about getting this merged ahead of pending Gutenberg fixes? The only one that affects usability is WordPress/gutenberg#12855 which leaves the experience broken for keyboard users if unmerged.

Doing so would be on the assumption that these get merged, but allow the continuation of work on filters. In the worst case, we can swap out GB components retrospectively.

@psealock psealock force-pushed the update/calendar-component-inline-picker branch from 4b6fbda to 12bec92 Compare December 20, 2018 22:58
dateFormat={ dateFormat }
invalidDays="none"
onUpdate={ onDatePickerUpdate }
invalidDays="future"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

note to self: invalidDays and onUpdate are duplicated

Copy link
Contributor

@timmyc timmyc left a comment

Choose a reason for hiding this comment

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

One minor comment in the code, but testing out nicely. Verified all seems well with current datepicker usage. I'm fine with landing this before the gberg PRs are merged myself.

packages/components/src/calendar/input.js Show resolved Hide resolved
@psealock
Copy link
Collaborator Author

Thanks for the review @timmyc !

PropType changes and example.md fixed.

Given the open issues with Gutenberg, I created an issue so we don't lose track of testing this for a11y when those get merged upstream #1145.

@psealock psealock merged commit 32885f1 into master Dec 21, 2018
@psealock psealock deleted the update/calendar-component-inline-picker branch December 21, 2018 02:25
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
focus: accessibility The issue/PR is related to accessibility. focus: components Issues for woocommerce components status: blocked The issue is blocked from progressing, waiting for another piece of work to be done.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants