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

Remove label from dataview checkbox #67868

Merged
merged 14 commits into from
Jan 3, 2025

Conversation

karthick-murugan
Copy link
Contributor

What?

Fixes #59178

This PR updates the labels associated with checkboxes in data views to remove the dynamically generated state values (Select item: and Deselect item:). The labels now display only the relevant item title, simplifying and improving accessibility.

Why?

The current implementation of checkbox labels includes dynamic state indicators (Select item: and Deselect item:) which
overcomplicate the labels and do not adhere to the semantic purpose of labels as descriptors of the control.

How?

Removed the dynamic prefixes (Select item: and Deselect item:) from the checkbox labels in the code. Updated the label to display only the item's title, derived from the provided titleField property.

Testing Instructions

  • Navigate to the Site Editor > Pages > Manage all pages.
  • Hover over a table row to make the checkbox visible.
  • Verify that the label for each checkbox contains only the item's title.
  • Select and deselect a checkbox.
  • Confirm that the label text remains unchanged and only displays the item title.

Screenshots or screencast

REC-20241212152215.mp4

Copy link

github-actions bot commented Dec 12, 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.

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

Co-authored-by: karthick-murugan <[email protected]>
Co-authored-by: afercia <[email protected]>
Co-authored-by: t-hamano <[email protected]>
Co-authored-by: alexstine <[email protected]>
Co-authored-by: ntsekouras <[email protected]>

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

@karthick-murugan
Copy link
Contributor Author

@t-hamano , @afercia - Please have a look at this PR when you get some time. Thanks in advance.

@afercia
Copy link
Contributor

afercia commented Dec 18, 2024

I'd totally support not using dynamic labels. Labels determine the accessible name of a control, which should rarely change dynamically. For checkboxes, the checked state is implied and natively communicated to assistive technologies.

@afercia
Copy link
Contributor

afercia commented Dec 18, 2024

A pre-existing issue is that selectionLabel may be not set. In that case, the checkbox would be unlabelled which is a no-go for accessibility. Unfortunately the base component like CheckboxControl do not enforce the label prop so that I wonder if we should provide a fallback label here.

Copy link
Contributor

@afercia afercia left a comment

Choose a reason for hiding this comment

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

Shouldn't aria-label={ selectionLabel } be just the label prop?

@karthick-murugan
Copy link
Contributor Author

Shouldn't aria-label={ selectionLabel } be just the label prop?

Replacing aria-label with the label prop results in the label being visually displayed next to the checkbox (which may not be desirable in this context)

A pre-existing issue is that selectionLabel may be not set. In that case, the checkbox would be unlabelled which is a no-go for accessibility. Unfortunately the base component like CheckboxControl do not enforce the label prop so that I wonder if we should provide a fallback label here.

You’re absolutely right, an unlabelled checkbox would be a critical accessibility issue. I will ensure that if the selectionLabel is not set or is empty, a fallback label such as "Select item" or the item's title is used as a default.

@karthick-murugan
Copy link
Contributor Author

@afercia, @t-hamano - Updated the code such that, default fallback ('Select item') is provided to ensure that every checkbox is accessible even if titleField is not defined.

Copy link
Contributor

@t-hamano t-hamano left a comment

Choose a reason for hiding this comment

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

This change makes sense to me. Screen readers appear to work properly both with and without titles:

54d09f32641d1b647adf7d87639487f7.mp4

@afercia Any additional feedback would be appreciated.

@karthick-murugan
Copy link
Contributor Author

@afercia - Please let us know if you have any additional comments, or else we can move forward. Thank you

@karthick-murugan
Copy link
Contributor Author

@t-hamano - If everything is fine, can we move forward merging this PR? Thanks in advance.

@afercia
Copy link
Contributor

afercia commented Jan 2, 2025

From an accessibility perspective I have no additional feedback, this looks good to me. Thanks!
@WordPress/gutenberg-core a review would be appreciated, when you have a chance.

@t-hamano
Copy link
Contributor

t-hamano commented Jan 3, 2025

It also looks ok from an accessibility standpoint, so let's ship this PR.

@t-hamano t-hamano added [Type] Bug An existing feature does not function as intended [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). labels Jan 3, 2025
@t-hamano t-hamano added the [Feature] DataViews Work surrounding upgrading and evolving views in the site editor and beyond label Jan 3, 2025
@t-hamano t-hamano merged commit 89de183 into WordPress:trunk Jan 3, 2025
68 of 70 checks passed
@github-actions github-actions bot added this to the Gutenberg 20.1 milestone Jan 3, 2025
@dilipom13
Copy link

Hello @t-hamano as per your thoughts, it's working properly.

bph pushed a commit to bph/gutenberg that referenced this pull request Jan 8, 2025
* Image size fix in lightbox

* Revert "Image size fix in lightbox"

This reverts commit 63f81c1.

* Remove label from dataview checkbox

* Feedback changes

* Feedback Changes

Co-authored-by: karthick-murugan <[email protected]>
Co-authored-by: afercia <[email protected]>
Co-authored-by: t-hamano <[email protected]>
Co-authored-by: alexstine <[email protected]>
Co-authored-by: ntsekouras <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] DataViews Work surrounding upgrading and evolving views in the site editor and beyond [Focus] Accessibility (a11y) Changes that impact accessibility and need corresponding review (e.g. markup changes). [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Data views: Improve the checkboxes labels
4 participants