-
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
Use immutableSet utility to set style properties #49365
Conversation
* @param {*} value New value to set. | ||
* @return {Object} Cloned object with the new value set. | ||
*/ | ||
export function immutableSet( object, path, value ) { |
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.
I didn't make any change to the utility, I just moved it to a better place (utils for the whole package and not just hooks)
Size Change: -235 B (0%) Total Size: 1.34 MB
ℹ️ View Unchanged
|
Going to merge this as a small non impactful refactoring. |
I haven't been able to go through the entire PR (at a meetup this week), but this looks like a nice improvement, thanks 👍 |
I think this PR might have introduced an error in global styles when adjusting padding values at the root level. I have a fix over in #49465 — I didn't look closely at this code, but just fixed the error that's failing, so there could be a better way to go about it. Feel free to close that PR if there's a better fix! |
* @param {*} value New value to set. | ||
* @return {Object} Cloned object with the new value set. | ||
*/ | ||
export function immutableSet( object, path, value ) { |
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.
I found this name super confusing because it sounds like a constructor for a kind of Set that is immutable (e.g. frozenset
). The docstring is also confusing.
Alternative names: setImmutably
, immutablySet
.
Alternative description: Immutably sets a value inside an object. Like lodash#set, but returning a new object.
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.
-> #50040
* Block Editor: Rename immutableSet to setImmutably Addresses #49365 (comment) * Add breaking change to CHANGELOG.md
Hi @youknowriad Is it possible this PR introduced a bug where all global settings are saved in global styles when updating the site layout in the dimensions panel? Please see here: #53868 |
@Andrew-Starr I've been able to reproduce the issue, I'll take a look. |
What?
I discovered recently that we have an
immutableSet
utility in the block-editor package, I'm just updating some existing code in global styles panels to use the utility instead of the nested spread approach that can be hard to read.Testing Instructions
Nothing really to test as the changes are straightforward but you could try to apply styles to several blocks.