Block Editor: Fix ZoomOutModeInserters dependencies#61908
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. |
|
Size Change: +1 B (0%) Total Size: 1.74 MB
ℹ️ View Unchanged
|
| setInserterIsOpened( true ); | ||
| // eslint-disable-next-line react-hooks/exhaustive-deps | ||
| }, [ blockOrder ] ); | ||
| }, [ blockOrder, setInserterIsOpened ] ); |
There was a problem hiding this comment.
I'm pretty sure I added this because it was misbehaving, but I can't remember after all the changes. What happens theoretically when the function changes? We only want to reset it when the order changes, so maybe we have to check that in the effect.
There was a problem hiding this comment.
Will this ever happen? It looks like a stable reference to me, so I don't understand when it will change. Plus we also have the mounted check. Happy to abandon it if I'm missing something of course.
There was a problem hiding this comment.
Right, actions should be safe to list in dependencies. If they're not anymore, we might have a bigger problem 😅
P.S. It would be cool if linter treated Redux actions as state setters, but IIRC that involved a lot of work.
There was a problem hiding this comment.
Sure, if everything works fine. I could swear I added it for a reason 😅
There was a problem hiding this comment.
We don't know it's an action though, it's a setting, right? I don't love these "impure" dependencies that much tbh
There was a problem hiding this comment.
What George said. Thanks for verifying it, folks 🙌
|
Flaky tests detected in 9aa58b8. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/9209487465
|
Co-authored-by: tyxla <tyxla@git.wordpress.org> Co-authored-by: ellatrix <ellatrix@git.wordpress.org> Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: tyxla <tyxla@git.wordpress.org> Co-authored-by: ellatrix <ellatrix@git.wordpress.org> Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
What?
This PR fixes the dependencies of one of
ZoomOutModeInserters'suseEffectcalls.Why?
From what I understand, there is no good reason not to provide
setInserterIsOpenedas a dependency:setInserterIsOpenedreference is a stable reference to a block editor store action function.The motivation is resolving an ESLint error that was raised by the React Compiler ESLint plugin in #61788
How?
By adding
setInserterIsOpenedas a dependency and removing the ESLint rule disabling.Testing Instructions
trunk(they look broken btw, but I'm not 100% sure how they are expected to look and work, cc @youknowriad)Testing Instructions for Keyboard
None
Screenshots or screencast
None