Skip to content

[6.x] Fix nested Bard data loss when editing a set#14808

Merged
jasonvarga merged 1 commit into
6.xfrom
fix-nested-bard-data-loss
Jun 11, 2026
Merged

[6.x] Fix nested Bard data loss when editing a set#14808
jasonvarga merged 1 commit into
6.xfrom
fix-nested-bard-data-loss

Conversation

@joshuablum

Copy link
Copy Markdown
Member

When using Bard with nested Bard fields, typing in one set causes another set's content to get cleared. That might happen without you even noticing like when it's further down the page. Saving the entry then leads to actual data loss.

Right now before typing:
image
After typing:
image

Reason is that Bard shares a single value tree and editing one set re-emits the array up to the publish container, which changes the value reference of every sibling and nested Bard set. Each Bard's value watcher reacts to that by running a destructive clearContent()/setContent() to rebuild its editor from the value. For an unfocused set, this rebuild happens while the publish container for that set is empty. The set rebuilds from the empty state and emits empty content back, which gets persisted on save.

This skips the destructive reset while a Bard editor is focused anywhere in the tree (document.activeElement is inside a .bard-content region).

External resets coming from things like field actions should be unaffected.

Closes #14759.

@jasonvarga jasonvarga merged commit 2b76510 into 6.x Jun 11, 2026
19 checks passed
@jasonvarga jasonvarga deleted the fix-nested-bard-data-loss branch June 11, 2026 15:23
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.

Nested bard set causes re-render and data loss

2 participants