-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
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. |
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.
Thank you, @tyxla!
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
|
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.
🚢
What?
This PR fixes a mutation that we're performing in
ScreenBlock
and 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