-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
RAC Breadcrumbs: add support for autoFocusCurrent #6325
Conversation
); | ||
|
||
let links = getAllByRole('link'); | ||
expect(links[2]).toHaveFocus(); |
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.
oo, nice, didn't know about this matcher. we can replace expect(document.activeElement).toBe(links[2])
everywhere eventually
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.
That would be an easy ast-grep codemod:
rule:
pattern: expect(document.activeElement).toBe($A)
fix: expect($A).toHaveFocus()
I'm actually curious if that matcher is any faster. If so, we could probably speed up our suite a good bit, as much as we check for focus.
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.
Just tried locally out of curiosity. Didn't clear cache or do any other isolation measures though:
Before:
Time: 192.227 s
After:
Time: 160.324 s
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.
hmm i wouldn't think it would be faster, document.activeElement is just an access to something already up to date, and then followed by an identity check. I imagine it's what the matcher is doing behind the scenes as well. ok, yep, it is, https://github.com/testing-library/jest-dom/blob/f03a582827453de6fac4510dcf4fa3148c7ed68a/src/to-have-focus.js#L7
so I'm betting you're seeing caching of some sort
Build successful! 🎉 |
## API Changes
unknown top level export { type: 'any' } |
For parity with RSP breadcrumbs: https://react-spectrum.adobe.com/react-spectrum/Breadcrumbs.html#props
✅ Pull Request Checklist:
📝 Test Instructions:
Check story, docs prop table, and test.
🧢 Your Project: