Block Editor: Don't memoize callbacks in 'BlockSettingsDropdown'#59397
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. |
There was a problem hiding this comment.
|
Size Change: -8 B (0%) Total Size: 1.71 MB
ℹ️ View Unchanged
|
52d4b80 to
01f02a0
Compare
tyxla
left a comment
There was a problem hiding this comment.
Good find for all 3 of them 👍 🚀
| }, | ||
| [ __experimentalSelectBlock ] | ||
| ); | ||
| async function updateSelectionAfterDuplicate( clientIdsPromise ) { |
There was a problem hiding this comment.
Only used inline; good to be un-memoized 👍
| if ( ! blockToFocus ) { | ||
| blockToFocus = getBlockOrder()[ 0 ]; | ||
| } | ||
| function updateSelectionAfterRemove() { |
There was a problem hiding this comment.
Only used inline; good to be un-memoized 👍
| }, | ||
| [ currentClientId, openedBlockSettingsMenu, setOpenedBlockSettingsMenu ] | ||
| ); | ||
| function onToggle( localOpen ) { |
There was a problem hiding this comment.
While this is passed down, it's passed down to useControlledValue():
which is then used for the initial value of useState(), thus is utilized only on the first useState() call anyway.
Good to be un-memoized as well 👍
| [ __experimentalSelectBlock ] | ||
| ); | ||
| async function updateSelectionAfterDuplicate( clientIdsPromise ) { | ||
| if ( ! __experimentalSelectBlock ) { |
There was a problem hiding this comment.
Thanks for reducing the nesting level here 👍
…dPress#59397) * Block Editor: Don't memoize callbacks in 'BlockSettingsDropdown' * Don't pass argument to 'updateSelectionAfterRemove' Co-authored-by: Mamaduka <mamaduka@git.wordpress.org> Co-authored-by: tyxla <tyxla@git.wordpress.org>
What?
PR removes unnecessary callback memoization in the
BlockSettingsDropdowncomponent.Why?
These callbacks aren't passed as effect dependencies or memoized component props. There's no need to ensure their stable reference.
Testing Instructions
Testing Instructions for Keyboard
Same.
Screenshots or screencast