Uh oh!
There was an error while loading. Please reload this page.
[6.x] Reduce publish container value cloning and emission overhead - #15261
Closed
jasonvarga wants to merge 2 commits into
Closed
[6.x] Reduce publish container value cloning and emission overhead#15261jasonvarga wants to merge 2 commits into
jasonvarga wants to merge 2 commits into
Conversation
The visibleValues computed cloned the entire values tree on every keystroke, even when field conditions had nothing to omit, which is the common case. Return the live tree by reference instead, and only clone when there is actually something to strip out.
Deep watching the visibleValues computed traversed the entire derived tree on every keystroke, on top of building it. visibleValues is derived from values and hiddenFields, so emit it alongside update:modelValue from the values watcher, and watch the much smaller hiddenFields object for the rest.
jasonvarga
commented
Aug 24, 2026
MemberAuthor
Closing this one — it's a breaking change.
The old clone was also normalizing via a JSON round trip, so Too much to put on a released line. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Extracted from #15158
The publish container's
visibleValuescomputed cloned the entire values tree —JSON.parse(JSON.stringify(...))viaValues— on every keystroke, and a separate deep watcher then re-traversed that derived tree in order to emit it. Neither is necessary in the common case.Two independent changes, in separate commits:
Skip the clone when nothing is omitted. Field conditions only omit values when a field is hidden with
omitValue. When nothing is omittable — the common case —visibleValuesnow returns the live tree instead of a copy. The cloning path is unchanged when there is actually something to strip out.Emit without deep watching the derived tree.
visibleValuesis derived fromvaluesandhiddenFields, so it's now emitted alongsideupdate:modelValuefrom the existingvalueswatcher, and the separate deep watcher watches the much smallerhiddenFieldsobject rather than re-traversing the whole values tree.Emission behaviour is unchanged. I traced the emission sequence on
6.xand on this branch with the same instrumented test, and the count, order and payloads are identical for value edits, nested edits, wholesale replacement viasetValues, and conditions toggling a field on or off.Nothing here touches which fields get omitted.
One note for addon authors: on the non-omitting path
visibleValuesis now the live values tree rather than a copy, so it must be treated as read-only. Nothing in core mutates it, and nothing in core listens toupdate:visibleValues.Adds
resources/js/tests/components/ui/Publish/VisibleValues.test.js, covering the uncloned tree's equivalence to a clone (including identical serialization) and the emissions for each of the cases above.