-
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
Fix PostContent initial render by waiting for the canEdit request #48642
Conversation
Size Change: +4 B (0%) Total Size: 1.33 MB
ℹ️ View Unchanged
|
@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? |
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.
LGTM 👍
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. |
What?
Fix
PostContent
block initial render by waiting until theuseCanEditEntity
request is resolved.Related: #48138 (comment)
Why?
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 thecanEdit
value 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
canEdit
state is established.How?
Wait until the
useCanEditEntity
hook (via thecanUserEditEntityRecord
request) 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