-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Fix #4259: Add the aria-disabled on the Time component's disabled time units #4319
Fix #4259: Add the aria-disabled on the Time component's disabled time units #4319
Conversation
Moved the logic to find whether a time is disabled logic to a helper method to reuse the logic both for the add of react-datepicker__time-list-item--disabled class ans also for the add of aria-disabled attribute Closes Hacker0x01#4259
…Time component Ensure the test cases to accurately check for the presence of 'aria-disabled' attribute in the Time component when it's disabled Closes Hacker0x01#4259
…times_test.js Migrated the test cases to RTL as mentioned by @martijnrusschen in the issue Hacker0x01#4300 for React 18 upgrade
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅ This pull request was sent to the PullRequest network.
@balajis-qb you can click here to see the review status or cancel the code review job.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PullRequest Breakdown
Reviewable lines of change
+ 35
- 17
65% JavaScript (tests)
35% JavaScript
Type of change
Fix - These changes are likely to be fixing a bug or issue.
Codecov Report
@@ Coverage Diff @@
## main #4319 +/- ##
=======================================
Coverage 96.63% 96.63%
=======================================
Files 27 27
Lines 2374 2376 +2
Branches 966 967 +1
=======================================
+ Hits 2294 2296 +2
Misses 80 80
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updates the aria-disabled attribute as described and updates tests accordingly. The code looks proper and reasonable and I see no reasons to prevent this from moving forward
Reviewed with ❤️ by PullRequest
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can see the change you have made around aria-disable. I have a suggestion for how to do the tests slightly different so that the code base is easier to work with for the next person. Great to see the tests! Nice work!
Reviewed with ❤️ by PullRequest
".react-datepicker__time-list-item--disabled", | ||
); | ||
expect(disabledItems).toHaveLength(45); | ||
expect(disabledTimeItems.length).toBe(45); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like it would make the test have a higher than necessary amount of maintenance. If something is added to the UI it would alter this count .. right? I would recommend writing this in a way that the functionality of the aria-disabled is verified to work. For example, you probably didn't go through and count to make sure that 45 is the right number ... I'm guessing the test failed and saw it was 45?
In summary, I'm suggesting:
- export or move the new
isDisabledTime
function and write a unit test against that little bit of logic. - Remove the assertions around number of nodes.
- Determine a filter that selects the nodes which should have aria-disabled (
input
,[onClick]
, etc), and write a test that selects those nodes and simply verify that aria-disabled is set. Thus catching new elements which are missing the attribute. Maybe have a list of some kind (or an custom attribute to suppress) that would make an exception if the filter is too broad.
🔹 Best Practices (Nice to have)
Revised test cases to ensure that all the disabled time items have the 'aria-disabled' attribute set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thanks for the refactor as well, that's making the future tests a lot more future proof. |
Closes #4259
Summary
This PR addresses an issue where the Time component is missing the attribute
aria-disabled
on it's disabled items.Changes made
aria-disabled
attribute over it's disabled itemsaria-disabled
attribute along with the class.react-datepicker__time-list-item--disabled
RTL
fromenzyme
as suggested by @martijnrusschen in the issue Rewrite usage of ReactDOM.render to React 18 #4300 for React 18 upgrade