[4.x] Prevent Bard causing dirty state issues #9344
Merged
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.
After doing some digging into #9294, I managed to track down Bard as the culprit of the dirty state issues.
After an entry is saved, the publish form values get updated. This consequently triggers Bard's
value
to be updated, which causes Bard to think it'sjson
has changed and it needs to emit the updated value upwards.However... in comparing the string-ified JSON with the actual
value
being passed into Bard, they were exactly the same. Yet, because it was emitted up the chain, it triggered the dirty state.This only seems to be an issue when you have a few different sets open because it needs to take over 360ms (the timeout on
PublishForm@runAfterSaveHook
) to parse the JSON, stringify it again and do whatever else it needs to do, before thesetTimeout
re-enables the dirty state tracking.I've put this fix directly into the
BardFieldtype
. However, let me know if you'd prefer this to be fixed in theFieldtype
mixin instead.Fixes #9294.