-
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
Reduce number of List View re-renders while typing #51518
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -187,16 +187,27 @@ export function getBlocks( state, rootClientId ) { | |
* Returns a stripped down block object containing only its client ID, | ||
* and its inner blocks' client IDs. | ||
* | ||
* @deprecated | ||
* | ||
* @param {Object} state Editor state. | ||
* @param {string} clientId Client ID of the block to get. | ||
* | ||
* @return {Object} Client IDs of the post blocks. | ||
*/ | ||
export const __unstableGetClientIdWithClientIdsTree = createSelector( | ||
( state, clientId ) => ( { | ||
clientId, | ||
innerBlocks: __unstableGetClientIdsTree( state, clientId ), | ||
} ), | ||
( state, clientId ) => { | ||
deprecated( | ||
"wp.data.select( 'core/block-editor' ).__unstableGetClientIdWithClientIdsTree", | ||
{ | ||
since: '6.3', | ||
version: '6.5', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the current consensus is that we won't remove deprecated APIs. We can omit targeted versions for removal, at least for now. |
||
} | ||
); | ||
return { | ||
clientId, | ||
innerBlocks: __unstableGetClientIdsTree( state, clientId ), | ||
}; | ||
}, | ||
( state ) => [ state.blocks.order ] | ||
); | ||
|
||
|
@@ -205,16 +216,26 @@ export const __unstableGetClientIdWithClientIdsTree = createSelector( | |
* given root, consisting of stripped down block objects containing only | ||
* their client IDs, and their inner blocks' client IDs. | ||
* | ||
* @deprecated | ||
* | ||
* @param {Object} state Editor state. | ||
* @param {?string} rootClientId Optional root client ID of block list. | ||
* | ||
* @return {Object[]} Client IDs of the post blocks. | ||
*/ | ||
export const __unstableGetClientIdsTree = createSelector( | ||
( state, rootClientId = '' ) => | ||
getBlockOrder( state, rootClientId ).map( ( clientId ) => | ||
( state, rootClientId = '' ) => { | ||
deprecated( | ||
"wp.data.select( 'core/block-editor' ).__unstableGetClientIdsTree", | ||
{ | ||
since: '6.3', | ||
version: '6.5', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same. |
||
} | ||
); | ||
return getBlockOrder( state, rootClientId ).map( ( clientId ) => | ||
__unstableGetClientIdWithClientIdsTree( state, clientId ) | ||
), | ||
); | ||
}, | ||
( state ) => [ state.blocks.order ] | ||
); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
When a block is disabled and its children aren't, this function will merge the children as the disabled block's siblings. I.e., this:
will become:
This behavior already existed before this PR, but I find it suprising. Do we really want to display the list view tree like this? I would expect such a disabled block to be greyed out.
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.
Yeah this was the design decision. It mimics the list view that you get in the right hand sidebar when editing a page or using a content locked pattern.
We can always revisit based on user feedback 😀