cms icon indicating copy to clipboard operation
cms copied to clipboard

Improve handling of invalid Replicator and Bard field data

Open jacksleight opened this issue 3 years ago • 1 comments

When a Replicator or Bard field contains invalid data, for example a set that has no configuration or a node for an extension that isn’t enabled, the feedback in the CP can be a little mysterious:

  • Replicator fields with an invalid set will render an empty item: Screenshot 2022-09-13 at 12 27 00
  • Bard fields with an invalid set will render the raw json (because the BardSet component errors): Screenshot 2022-09-13 at 12 27 07
  • Bard fields with invalid nodes/marks end up with a completely blank value.

This PR aims to improve this by fixing the BardSet error, checking for invalid data, and adding invalid states (a bit like the Entries and Assets fieldtypes have):

Screenshot 2022-09-13 at 10 07 31

The idea was just to give a bit of a hint about what the problem is, but more details could be added or logged to the console. Tiptap already logs errors when it runs into invalid nodes/marks.

Here is a blueprint and entry for testing invalid values: https://gist.github.com/jacksleight/8d936be1f4966ca9833cbcf52dd697ec

Fixes https://github.com/statamic/cms/issues/6143

jacksleight avatar Sep 13 '22 11:09 jacksleight

OMG I love this one so much

edalzell avatar Sep 13 '22 16:09 edalzell

thank you thank you thank you

edalzell avatar Sep 23 '22 19:09 edalzell