-
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
Tooltip: Fix Ariakit tooltip store usage #61858
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Flaky tests detected in 98fa4cc. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/9189637481
|
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, @tyxla!
We also need to figure out how to handle warnings/errors for Ariakit's store hooks.
const compositeStore = useCompositeStore();
const activeId = compositeStore.useState( 'activeId' );
Definitely. Might need some additional wrapper, in Ariakit or here, in the package. One simple solution I can think of is having a separate |
@diegohaz @DaniGuardiola is this a problem you've encountered and/or thought about already in Ariakit? |
I'm not sure I'm aware of that problem. Could you elaborate? |
We're trying out the new React Compiler ESLint plugin in #61788 It will complain that hooks can't be just dynamically declared or assigned somewhere. So in code like @Mamaduka provided above:
it will complain because the To solve this issue, |
@diegohaz, the following code triggers a warning/error when enabling the new React compiler ESLint rules.
gutenberg/packages/components/src/alignment-matrix-control/index.tsx Lines 59 to 71 in 6e8c261
|
I see. Ariakit has an experimental const activeId = useStoreState(compositeStore, 'activeId'); This is essentially what |
I think that might be the case. Thanks for considering it. Also, cc @DaniGuardiola who's working on the Ariakit upgrade in #60992 |
@tyxla I'm not sure this PR is doing anything other than trick eslint into thinking there's no hook to analyze. The React linting tule is just too dumb to identify namespaces hooks as such, but it is still a hook and it should still respect the rules of hooks that eslint complained about. Separately, we should wrap these hooks into ones that throw if the context is not present, so that no conditional logic is necessary (this is also what we discussed regarding Tabs). Edit: I think I misunderstood, will check again once I'm back from lunch. |
* Tooltip: Fix Ariakit tooltip store usage * CHANGELOG Co-authored-by: tyxla <tyxla@git.wordpress.org> Co-authored-by: diegohaz <hazdiego@git.wordpress.org>
* Tooltip: Fix Ariakit tooltip store usage * CHANGELOG Co-authored-by: tyxla <tyxla@git.wordpress.org> Co-authored-by: diegohaz <hazdiego@git.wordpress.org>
What?
This PR fixes how we use the
Ariakit.useTooltipStore
hook in theTooltip
component.Why?
Previously, we were circumventing an ESLint error because the hook was conditionally called. I recall I suggested this workaround, so I'm glad I'm the one to suggest removing it now (see #57202 (comment)).
The workaround is no longer necessary since the hook is no longer called conditionally.
The motivation is that I'm fixing it to resolve a couple of ESLint errors that were raised by the React Compiler ESLint plugin in #61788
How?
Just using the hook directly.
Testing Instructions
Verify the static analysis check is still green.
Testing Instructions for Keyboard
None
Screenshots or screencast
None