-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
IconButton: refs
don't work
#12615
Comments
Played a bit with this:
Seems to me the first approach is preferable but this issue needs someone with expertise in building tests 🙂 |
I'd agree with this. Looking at the following, I think there was some hacking done to make Button and its Since that time, Enzyme has updated to provide more up-to-date adapters. Updating those may resolve some issue there to test the component. It's been on my task list to take a look at this. In parallel, it might make sense to push up what you have (even failing) as a pull request, and collaborate on resolving the test failures. |
Yep, spent some (too much) time on this and then saw the button mock, researched what the real problem was, and finally found the Enzyme issue with |
While
refs
on theButton
component work, they don't on theIconButton
component.IconButton
is a class that wrapsButton
and doesn't pass any ref toButton
, which in turn usesforwardRef()
.A similar case has been addressed for the
PanelBody
component, see:gutenberg/packages/components/src/panel/body.js
Lines 81 to 86 in 8743217
Not saying this is necessarily the best option, but being able to get a ref to
IconButton
would be nice. Worth remindingrefs
help in managing focus when necessary, so they are important for accessibility.The text was updated successfully, but these errors were encountered: