-
Notifications
You must be signed in to change notification settings - Fork 4.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
TabPanel: Refactor unit tests in prep for controlled component updates #48086
Conversation
Note: This PR is only a draft at this point as I'm a little short on time. If it isn't useful as a base to verify the current component on trunk before continuing #46704, please feel free to close it. There are some differences at this stage between the tests in this PR and those in #46704. These mostly revolve around the fact that it appears the proposed updates prevent I'll be AFK until late next week but I will try and keep an eye on this. If this PR helps at all please feel free to pick it up and push any desired changes or additional tests. Of course if I've gone down the wrong track with it, I'll happily close it. cc/ @ciampo, @madhusudhand |
Flaky tests detected in 4f919b4. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4262407876
|
Thanks Aaron — this PR is definitely on the right track! I gave it quick look, and I started leaving some notes about what other tests I'd like to add (under the shape of either code comments, or failing unit tests). If I get to it, I'll try to iterate and add those missing unit tests in the next days.
This is interesting, and something to consider for the changes in #46704 |
60e9cc9
to
1b5b810
Compare
@aaronrobertshaw I should have added unit tests for all scenarios that came to mind. Would you be able to give this PR a good look?
I also added a small improvement to the Storybook examples that I created while trying to understand tooltip behaviour when icons are defined for tabs. |
Thanks for all the work on this PR while I was AFK, I appreciate it 🙇 While checking out the new tabs with icons and tooltips story, I notice I couldn't navigate with the right arrow key. It appears that the tooltip is the culprit as its popover is being rendered inline. In the editor, I believe the tooltip popovers are rendered via a SlotFill and avoid this issue. Bug DemoScreen.Recording.2023-02-24.at.1.02.28.pm.mp4I tweaked the story to provide a We've done similar things with other components such as the
Other than potentially covering the keyboard navigation when tabs have tooltips, nothing else sprang to mind. The correct tests all made sense to me and ran successfully. Nice work. |
When tooltips are rendered inline i.e. within the tab's button, it interferes with keyboard navigation.
8a60962
to
4f919b4
Compare
Thank you for spotting that, @aaronrobertshaw ! I went ahead and applied your suggestions — testing keyboard interaction with tooltips, and using a dedicated I think this PR is good to go, and so I'm going to approve it (since you're the author), but I'll wait for your confirmation before merging.
I haven't looked too deep into it, but definitely something to keep an eye on — I wonder if the upcoming work on |
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.
Thanks @aaronrobertshaw, @ciampo.
Tests are neatly structured and they cover all the scenarios of uncontrolled mode.
Thanks for the tweaks and extra test covering the keyboard navigation and tooltips @ciampo 👍
I'm not certain. I'd probably need to see how we end up implementing the new Tooltip component. The underlying Ariakit component can render the Tooltip via a portal, which I think we'd want in regard to the TabPanel. How the Ariakit Portal component works with or can be replaced by our SlotFills is where I'd need to dig deeper. My guess is either way we'd need a wrapper of sorts around the storybook example.
The tweaks and new test look good. All unit tests are passing and the component behaves as expected in the Storybook and editors.
Looks like we're in a good position to move forward with offering TabPanel in a controlled mode. I'll go ahead and merge this one. |
Related:
TabPanel
#43414What?
TabPanel
unit tests in preparation for updating offeringTabPanel
as a controlled component.Why?
TabPanel
will certify current behaviour and provide greater confidence when updating the component.TabPanel
unit tests to usedescribe.each
will make it easier to test the proposed controlled version of this componentHow?
Testing Instructions
npm run test:unit:watch packages/components/src/tab-panel