Skip to content

[6.x] Keep Bard set node views alive across saves - #15689

Open
edalzell wants to merge 1 commit into
statamic:6.xfrom
edalzell:fix/bard-sync-set-values-in-place
Open

edalzell wants to merge 1 commit into
statamic:6.xfrom
edalzell:fix/bard-sync-set-values-in-place

Conversation

@edalzell

@edalzell edalzell commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

When Bard's value changes after a save, the editor was rebuilt with clearContent + setContent unless it was focused and only set values differed. The rebuild destroys every set NodeView, so nested fields lose their state, e.g. a Replicator with collapse: true inside a set re-reads meta.collapsed (which the save response resets) and an expanded set snaps shut. Reproduced by adding a Replicator row inside a Bard set and clicking Save.

Two kinds of diff now avoid the rebuild. Set-value-only differences (the response hands values back with keys reordered) are skipped regardless of focus, since sets already sync their own values into the editor. With remove_empty_nodes the response also lacks the empty paragraphs the editor still holds, so those are deleted in place with a transaction (mirroring Bard::removeEmptyNodes()), keeping a text selection so a set doesn't get node-selected and have its NodeView recreated by the decoration change.

Anything else still rebuilds, which keeps the #15440 fix. Persisting single-set collapse state to meta is #15688.

References #15687

@edalzell
edalzell requested a review from jaygeorge October 21, 2026 02:17
@edalzell
edalzell force-pushed the fix/bard-sync-set-values-in-place branch 2 times, most recently from 7100784 to 864a5ad Compare October 21, 2026 03:00
@edalzell edalzell changed the title [6.x] Sync Bard set values in place instead of rebuilding the editor [6.x] Keep Bard set node views alive across saves Oct 21, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant