You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Depending on the returned value from the useCanEditEntity hook, the PostContent block renders either in the read-only or editable mode. The problem is that the canEdit value can initially be undefined, so the content is rendered in the read-only mode by default. Once the value becomes defined (boolean), it either stays in the read-only mode or switches to the editable mode, which causes the whole body to rerender.
The following videos show the difference before and after the fix:
Wait until the useCanEditEntity hook (via the canUserEditEntityRecord request) returns a boolean value, and then render the content. This approach should be correct according to the documentation (see the last line):
@WunderBart I don't see anything in here that sticks out, but I'm a bit lost on what you would like reviewed. was there something specific you were interested in from my review?
@WunderBart I don't see anything in here that sticks out, but I'm a bit lost on what you would like reviewed. was there something specific you were interested in from my review?
This is related to the flakiness of the performance tests, so I figured you might be interested!
Aha, well thank you. I hope it helps! It does line up with my suspicion that we have fewer individual tests which themselves are flakey and instead have more systematic operations in the editor itself (and the test runners) which manifest themselves as flakiness in seemingly random tests.
This file contains hidden or 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.
What?
Fix
PostContentblock initial render by waiting until theuseCanEditEntityrequest is resolved.Related: #48138 (comment)
Why?
Depending on the returned value from the useCanEditEntity hook, the
PostContentblock renders either in the read-only or editable mode. The problem is that thecanEditvalue can initially beundefined, so the content is rendered in the read-only mode by default. Once the value becomes defined (boolean), it either stays in the read-only mode or switches to the editable mode, which causes the whole body to rerender.The following videos show the difference before and after the fix:
Screen.Recording.2023-03-01.at.14.31.45.mov
Screen.Recording.2023-03-01.at.14.32.59.mov
This behavior has also been a source of flakiness in our Site Editor performance tests as the initially rendered canvas nodes are detached once the
canEditstate is established.How?
Wait until the
useCanEditEntityhook (via thecanUserEditEntityRecordrequest) returns a boolean value, and then render the content. This approach should be correct according to the documentation (see the last line):gutenberg/docs/reference-guides/data/data-core.md
Lines 30 to 48 in 8dee3e6