-
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
Widgets editor saves all the widgets instead of just the changed ones #34335
Comments
This was the surprising bit for me while reading your description. I don't think |
@noisysocks I don't know enough about Why do we even use |
I don't know how |
It's just that
|
Feels like this logic should move to the "entities" config array somehow (not sure how exactly) |
@youknowriad I proposed a solution in #34388 |
Solved in #34388 |
Description
When I have a lot of legacy widgets and only update one of them, clicking "Update" still sends one (batched) API request per widgets, even for the ones that were not changed at all.
saveWidgetArea
has a check in place to prevent that situation, but it's not effective:gutenberg/packages/edit-widgets/src/store/actions.js
Lines 159 to 183 in be7954e
This is because the
editEntityRecord
call effectively passes the following diff:which then, in editEntityRecord, is compared against the data already stored in that widget entity:
gutenberg/packages/core-data/src/actions.js
Lines 276 to 286 in be7954e
The problem is that for the
instance
field theisEqual( recordValue, value )
effectively unfolds to this:Because the
recordValue
comes from therecord
retrieved viagetRawEntityRecord
where only theraw
value is returned when available:gutenberg/packages/core-data/src/selectors.js
Lines 208 to 216 in be7954e
Possible solutions
A workaround could involve not passing the
instance
toeditEntityRecord
if it hasn't changed – we can detect that insaveWidgetArea
.A more appropriate solution could involve not using
raw
data. I am not sure why we rely on it though, any ideas @noisysocks, @kevin940726?The text was updated successfully, but these errors were encountered: