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

Fix #4259: Add the aria-disabled on the Time component's disabled time units #4319

Conversation

balajis-qb
Copy link

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

  • Updated the Time component to add the aria-disabled attribute over it's disabled items
  • Made the logic to find the disable time unit sharable in a reusable helper function
  • Updated the corresponding test cases to also check for the existence of the aria-disabled attribute along with the class .react-datepicker__time-list-item--disabled
  • Migrated the test cases to use RTL from enzyme as suggested by @martijnrusschen in the issue Rewrite usage of ReactDOM.render to React 18 #4300 for React 18 upgrade

Balaji Sridharan added 3 commits October 14, 2023 23:30
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
Copy link

@pullrequest pullrequest bot left a 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.

Copy link

@pullrequest pullrequest bot left a 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
Copy link

codecov bot commented Oct 14, 2023

Codecov Report

Merging #4319 (48d06b4) into main (fa6d0c2) will increase coverage by 0.00%.
The diff coverage is 88.88%.

❗ Current head 48d06b4 differs from pull request most recent head fde2732. Consider uploading reports for the commit fde2732 to get more accurate results

@@           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           
Files Coverage Δ
src/time.jsx 90.26% <88.88%> (+0.17%) ⬆️

Copy link

@pullrequest pullrequest bot left a 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

Image of James D James D


Reviewed with ❤️ by PullRequest

Copy link

@pullrequest pullrequest bot left a 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!

Image of Steven S Steven S


Reviewed with ❤️ by PullRequest

".react-datepicker__time-list-item--disabled",
);
expect(disabledItems).toHaveLength(45);
expect(disabledTimeItems.length).toBe(45);
Copy link

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:

  1. export or move the new isDisabledTime function and write a unit test against that little bit of logic.
  2. Remove the assertions around number of nodes.
  3. 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)

Image of Steven S Steven S

Revised test cases to ensure that all the disabled time items have the 'aria-disabled' attribute set.
Copy link
Member

@martijnrusschen martijnrusschen left a comment

Choose a reason for hiding this comment

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

LGTM

@martijnrusschen
Copy link
Member

Thanks for the refactor as well, that's making the future tests a lot more future proof.

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.

Disabled time does not have aria-disabled attribute (unlike disabled dates)
2 participants