[6.x] Fix nested Bard data loss when editing a set#14808
Merged
Conversation
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 free
to 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.
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:


After typing:
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
valuereference of every sibling and nested Bard set. Each Bard'svaluewatcher reacts to that by running a destructiveclearContent()/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.activeElementis inside a.bard-contentregion).External resets coming from things like field actions should be unaffected.
Closes #14759.