-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Nesting: Fix broken nested content caused by overly aggressive cache #5043
Conversation
Cache must bust if any inner blocks change, which could correspond to other UIDs in set, can't just bust on parent block
editor/store/selectors.js
Outdated
@@ -428,8 +428,8 @@ export const getBlock = createSelector( | |||
innerBlocks: getBlocks( state, uid ), | |||
}; | |||
}, | |||
( state, uid ) => [ | |||
get( state, [ 'editor', 'present', 'blocksByUid', uid ] ), |
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.
Don't you think the fix should be to add a dependency to blockOrder[uid]
instead? I'm afraid this means all block rerenders if only one of them changes.
I don't think this would help, as it still needs to reflect changes to inner blocks even when the order hasn't changed.
Yes, this seems quite bad. I'm going to look into an alternative approach where changing an inner block also signals a change to its root block, and perhaps refactor the child -> root referencing in the process. |
I'm thinking we could revisit embedding the child blocks in the "block" object. and replace them with their UIDs instead. And if we want access to the innerBlocks (which should be very localized), we use another dedicated selector. What do you think? |
It seems convenient from a purely performance-oriented perspective, but not sure I'd agree that the canonical block object produced by a derived selector shouldn't also include its full children set. |
This reverts commit d577262.
Aside: We should probably move the |
A couple (very rough) iterations on ideas:
|
I proceeded with the first of the two above explored options in b8da050. It's a very opaque implementation, but hopefully clarified some with included documentation and unit tests. |
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.
Thanks Andrew, confirmed it's working properly.
Regression introduced in #5002 (1ce8079)
This pull request seeks to resolve an issue where the content within a nested block is not saved. The issue is that because the selector for
getBlock
was configured to cache with the individual block as a dependant, the cache is incorrectly not bust when any of its inner blocks change.Since 1ce8079 was introduced as a performance enhancement, we should separately seek to explore how we tailor the cache to be most specific to the individual block being queried (trigger change on parent when inner blocks change?)
Testing instructions:
Follow-up Tasks: