[6.x] Fix Bard set disappearing after save#14956
Merged
Merged
Conversation
Contributor
Author
|
I've done a manual test on a production website with this patch, and it seems to fix the issue without breaking anything (visible) 🙂 |
jasonvarga
approved these changes
Jul 8, 2026
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.
Fixes #14688.
Summary
This fixes a Bard CP sync issue where a Bard field containing only a single set could appear to lose that set after the first save when
remove_empty_nodesis configured to trim empty nodes at the start and end.The backend processing is not actually deleting the set. With
remove_empty_nodes: trim, PHP correctly trims the surrounding empty paragraph nodes and preserves the set. That also matches the reported behavior: refreshing the page makes the set appear again, which means the saved value is still present.The problem is in the frontend watcher that syncs an externally updated Bard value back into the Tiptap editor after save:
clearContent()emits an update with an empty paragraph beforesetContent()applies the real server value. For a Bard field whose server-trimmed value is only a set, that intermediate empty update can be picked up by the publish state, making the set disappear visually until the page is refreshed.This PR changes the clear step to be silent:
That keeps the editor replacement behavior the same, but avoids emitting the temporary empty Bard value. The final
setContent(content, true)still emits the real updated value.Tests
vendor/bin/phpunit tests/Fieldtypes/BardTest.phpnpm run testI also added a regression test confirming that trimming empty Bard nodes preserves a set surrounded by empty paragraphs.
Note
This PR is being submitted from eminos GitHub account, but the investigation, patch, and PR write-up were prepared by Codex GPT 5.5.