Edit Site: Fix settings mutation in ScreenBlock#67085
Conversation
|
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: +38 B (0%) Total Size: 1.82 MB
ℹ️ View Unchanged
|
|
Failing e2e tests seem related. I'll be taking a look (likely tomorrow). |
9b3e253 to
6e5ee3a
Compare
Actually, fixed, it was a silly bug. @Mamaduka could you take another look when you get a chance? |
|
Flaky tests detected in 6e5ee3a. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/11894960106
|
What?
This PR fixes a mutation that we're performing in
ScreenBlockand updates to use a new object instead.Why?
Mutating objects could lead to subtle bugs.
In this particular case, I'm fixing it to resolve an ESLint error that was raised by the React Compiler ESLint plugin in #61788
How?
Using a new object instead of mutating the existing one.
Since this already memoized object is used in plenty of places, I'm introducing some memoization to preserve the original behavior and have as little performance impact as possible. We're using boolean flags to ensure the change happens only if necessary.
The fix isn't ideal. Ideally, this should be part of the
useSettingsForBlockElement()hook; however, I'm concerned that this hook is used in a few other places, but the workarounds are only in one of them. That's why I chose to do it inline and preserve the pre-existing behavior. I'm planning to monitor performance metrics after shipping.Testing Instructions
Testing Instructions for Keyboard
None
Screenshots or screencast
None