PaletteEditListView: add missing deps to useEffect dep array#43911
PaletteEditListView: add missing deps to useEffect dep array#43911flootr wants to merge 2 commits intoWordPress:trunkfrom
PaletteEditListView: add missing deps to useEffect dep array#43911Conversation
PaletteEditListView: add missing deps to useEffect dep arrayPaletteEditListView: add missing deps to useEffect dep array
5ba042e to
b9e161b
Compare
|
Unfortunately no Storybook example was added for this component. It looks like this component is used in the Global Styles sidebar, in the Site Editor — I took this PR for a spin and noticed that it introduces a regression when trying to add a new color to the palette: Kapture.2022-09-10.at.18.50.38.mp4It looks the changes from this PR make the cleanup function from We have a couple of choices:
In the process, it would be also great if we could add unit tests to catch this regression in the future. |
It looks like this is happening because:
To test this theory, I tried quickly wrapping Screen.Recording.2022-09-14.at.15.42.01.movSorting out that first usage of the |
|
Circling back to this one... I'm thinking it might make the most sense to revert the changes related to |
|
Sounds like a plan to me |
jorgefilipecosta
left a comment
There was a problem hiding this comment.
- try to change the logic of the component so that effectively the "cleanup" is run only when the user is done editing the palette (@jorgefilipecosta may help here?)
I was not involved in coding this logic, so I don't have many insights. But It sounds like the logic was added there as a workaround that we want to run when unmounting, so adding the missing deps would break the logic. I don't think we should invest much time into this, so probably a lint ignore comment is the way to go here.
|
Hey @flootr , do you intend to pick this PR up or should we close it? |
Let's close it for now. I'll add a note to follow up. |
What?
Updates the
PaletteEditListViewcomponent to satisfy theexhaustive-depseslint ruleWhy?
Part of the effort in #41166 to apply
exhaustive-depsto the Components packageHow?
Add the
onChangeprop &slugPrefixto theuseCallbackdependency array.Testing Instructions
npx eslint --rule 'react-hooks/exhaustive-deps: warn' packages/components/src/palette-edit