BlockSettingsDropdown: No need to cast 'clientIds' to an array#59940
BlockSettingsDropdown: No need to cast 'clientIds' to an array#59940
Conversation
| const clientId = Array.isArray( clientIds ) | ||
| ? clientIds[ 0 ] | ||
| : clientId; | ||
| insertBeforeBlock( clientId ); |
There was a problem hiding this comment.
Great catch, thanks I confirm this had to be clientIds in the first place!
|
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: 0 B Total Size: 1.71 MB ℹ️ View Unchanged
|
| const clientId = Array.isArray( clientIds ) | ||
| ? clientIds[ 0 ] | ||
| : clientId; | ||
| insertBeforeBlock( clientId ); |
There was a problem hiding this comment.
Great catch, thanks I confirm this had to be clientIds in the first place!
| insertBeforeBlock( clientIds[ 0 ] ); | ||
| }, | ||
| onInsertAfter() { | ||
| const clientId = Array.isArray( clientIds ) |
There was a problem hiding this comment.
Confirming that the rest of the code already expects arrays and doesn't do additional checks. Good find!
|
Thanks for the review, @tyxla! |
…ress#59940) * BlockSettingsDropdown: No need to cast 'clientIds' to an array * Fix clientId logic for 'onInsertBefore' and 'onInsertAfter' actions Co-authored-by: Mamaduka <mamaduka@git.wordpress.org> Co-authored-by: tyxla <tyxla@git.wordpress.org>
What?
PR removes unnecessary casting to an array of
clientIdsfor theBlockSettingsDropdownand fixes leftover logic inBlockActionscomponent.Why?
The parent
BlockSettingsMenucomponent always receivesclientIdsas an array.getSelectedBlockClientIdsselector, which always returns an array.Testing Instructions
Testing Instructions for Keyboard
Same.
Screenshots or screencast