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/Fix Accessibility for WeekdayPicker Component for Screen reader #6055

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Abishekcs
Copy link
Contributor

@Abishekcs Abishekcs commented Dec 9, 2024

closes #6051

What this PR does

This PR fixes the accessibility of the Calendar and WeekdayPicker components by introducing the aria-label and removing aria-pressed. And prop ariaModifier which was not being used was replaced by a simple hardcoded string which is used to detect if a "weekday" is selected.


Cause of the Bug:

The ariaModifier prop (of type PropTypes.string) required by the WeekdayPicker component was not being passed from the Calendar component or any of its parent components. This prop is essential for determining whether a button has been pressed and updating the aria-pressed attribute accordingly. As a result, the aria-pressed attribute remained false even when the button was pressed because it depended on the correct value of ariaModifier. Which was not passed in the first place itself.


Screenshots

Before:

Before.mp4

After:

2024-12-11.15-43-50.mp4

Open questions and concerns

I applied CSS to hide the aria-live div (weekday_picker.jsx), using a style similar to that already used for hiding admin notes. Although the two elements use different class names, the CSS properties are the same. I considered using a single shared CSS class for both cases but was uncertain about the best file to place this shared CSS in.

@Abishekcs Abishekcs marked this pull request as ready for review December 9, 2024 17:49
@Abishekcs Abishekcs marked this pull request as draft December 9, 2024 18:06
@Abishekcs Abishekcs marked this pull request as ready for review December 10, 2024 12:27
@@ -151,6 +152,7 @@ const Calendar = createReactClass({

const onWeekdayClick = this.props.editable ? this.selectWeekday : null;
const onDayClick = this.props.editable ? this.selectDay : null;
const ariaModifier = this.props.useAriaLabel ? 'selected' : null;
Copy link
Member

Choose a reason for hiding this comment

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

Why is it necessary to make changes outside of the WeekdayPicker component for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, I reviewed the code again and realized this change is not necessary. I have removed the existing ariaModifier since the WeekdayPickerComponent was not using it at all, and the Calendar component was not passing it either. I replaced it with the hardcoded string selected.

Additionally, I removed aria-pressed and replaced it with aria-label & aria-live.

Also, since the WeekdayPickerComponent is only used by the Calendar component, this change should not cause any issues.

Can you please review the updated code whenever you have time? Thank you 😃

@Abishekcs Abishekcs force-pushed the fix/screen-reader-weekdaypicker-accessibility branch 2 times, most recently from ca0e166 to 82281b9 Compare December 11, 2024 09:44
…ve support

- Add `aria-label` and `aria-live` for improved screen reader compatibility.
- Add CSS styling for the `aria-live` region to ensure proper visibility and user experience.
- remove aria-pressed
@Abishekcs Abishekcs force-pushed the fix/screen-reader-weekdaypicker-accessibility branch from 82281b9 to a7eaabc Compare December 20, 2024 13:42
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.

WeekdayPicker state is not fully accessible via screen reader
2 participants