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

TimePicker: use ToggleGroupControl for AM/PM toggle #64800

Merged
merged 5 commits into from
Aug 26, 2024

Conversation

ciampo
Copy link
Contributor

@ciampo ciampo commented Aug 26, 2024

What?

Closes #61163

Use ToggleGroupControl in TimePicker instead of button

Why?

For better semantics and screen readers support (ToggleGroupControl implements radio semantics)

How?

  • swap out ButtonGroup and Button for ToggleGroupControl and ToggleGroupControlOption;
  • use the onChange callback instead of onClick handlers
  • update tests to reflect the new semantics

Testing Instructions

  • Test component both in Storybook and in the editor (for example, by setting a future publishing date for a post)
  • Make sure that the AM/PM toggle is shown (that happens if the is12Hour prop is true)
  • Make sure that the datetime is updated correctly as the toggle is interacted with (including first load)
  • Make sure that the new version of the toggle implements radio semantics correctly and is accessible for screen reader users

Screenshots or screencast

Before (trunk) After (this PR)
Screenshot 2024-08-26 at 15 24 49 Screenshot 2024-08-26 at 15 25 04

@ciampo ciampo self-assigned this Aug 26, 2024
@ciampo ciampo changed the title TimePicker: use ToggleGroupControl instead of ButtonGroup TimePicker: use ToggleGroupControl for AM/PM toggle Aug 26, 2024
@ciampo ciampo marked this pull request as ready for review August 26, 2024 13:25
@ciampo ciampo requested a review from ajitbohra as a code owner August 26, 2024 13:25
Copy link

github-actions bot commented Aug 26, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @MadGanGithub.

Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Unlinked contributors: MadGanGithub.

Co-authored-by: ciampo <[email protected]>
Co-authored-by: mirka <[email protected]>
Co-authored-by: jasmussen <[email protected]>
Co-authored-by: jameskoster <[email protected]>
Co-authored-by: patil-vipul <[email protected]>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@ciampo ciampo requested review from a team August 26, 2024 13:26
@ciampo ciampo added [Type] Enhancement A suggestion for improvement. [Package] Components /packages/components [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). labels Aug 26, 2024
Copy link
Member

@mirka mirka left a comment

Choose a reason for hiding this comment

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

Looks good 🚀

@@ -9,6 +9,7 @@
### Enhancements

- `ColorPicker`: Adopt radius scale ([#64693](https://github.com/WordPress/gutenberg/pull/64693)).
- `TimePicker`: use ToggleGroupControl for AM/PM toggle ([#64800](https://github.com/WordPress/gutenberg/pull/64800)).
Copy link
Member

Choose a reason for hiding this comment

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

I think we can frame this as a full-on bug fix since it was previously inaccessible.

>
<Button
<ToggleGroupControlOption
className="components-datetime__time-am-button" // Unused, for backwards compatibility.
Copy link
Member

Choose a reason for hiding this comment

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

Do you think we can remove this className now? I can't really imagine a style override that was applied on the previous implementation that would still work as intended in the new implementation 😂

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The components-datetime__time-field is actually used in more places throughout the component, but for the scope of this PR I've only removed it from ToggleGroupControl.

If you think it makes sense, I can open a follow-up removing those other instances too.

@ciampo ciampo force-pushed the fix/date-time-picker/am-pm-switch-toggle-group-control branch from 39b1f5e to 4fdb477 Compare August 26, 2024 17:02
@ciampo ciampo enabled auto-merge (squash) August 26, 2024 17:03
@ciampo ciampo merged commit 23b7baf into trunk Aug 26, 2024
62 checks passed
@ciampo ciampo deleted the fix/date-time-picker/am-pm-switch-toggle-group-control branch August 26, 2024 18:45
@github-actions github-actions bot added this to the Gutenberg 19.2 milestone Aug 26, 2024
bph pushed a commit to bph/gutenberg that referenced this pull request Aug 31, 2024
* TimePicker: use ToggleGroupControl instead of ButtonGroup

* Update unit tests

* CHANGELOG

* Move changelog entry to bug fixes

* Removed legacy classnames

---

Unlinked contributors: MadGanGithub.

Co-authored-by: ciampo <[email protected]>
Co-authored-by: mirka <[email protected]>
Co-authored-by: jasmussen <[email protected]>
Co-authored-by: jameskoster <[email protected]>
Co-authored-by: patil-vipul <[email protected]>
@jeffpaul
Copy link
Member

jeffpaul commented Nov 8, 2024

@MadGanGithub mind sharing your WordPress.org username so I can ensure its included in the 6.7 credits listing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Package] Components /packages/components [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DateTimePicker: AM/PM switcher is not screen reader accessible
3 participants