- πΊπΈUnited States angelamnr
The issue is still occurring with the new/experimental widget. So far, I've only noticed it with paragraphs that have an image upload field.
To replicate:
- Build a stock Drupal site with the Standard installation profile. Also install paragraphs.
- Create a new paragraph type.
- Add an image upload field to your new paragraph type. Use all the default values when setting up your image field.
- Create a custom block type.
- Add a paragraph field to your new custom block type. Make sure to allow adding the new paragraph type you just created.
- Create a content block using the new custom block type that you just created. Add an image to the paragraph in your block. Fill out any other required fields. Save.
- Edit the content block that you just created. Collapse all of the paragraphs. Note that your paragraph has unsaved changes, which is impossible because you have not made any changes since saving.
The isChanged() method in the Paragraphs entity class compares the latest revision of each field to the version that is currently present in the form when the accordion is collapsed. The latest revision of the ImageItem field contains height and width data that does not exist in the current version. The values in the ImageItem revision will look something like this:
values => { target_id => 1, alt => "test image", title => "", width => "2000", height => "500", }
The values in the current ImageItem will look like this even when there aren't any changes to it:
values => { alt => "test image", display => 1, description => "", upload_button => {Drupal\Core\StringTranslation\TranslatableMarkup} remove_button => {Drupal\Core\StringTranslation\TranslatableMarkup} upload => "", title => "", target_id => 1, }
In FieldItemList::equals, this is filtered down to this for the ImageItem revision before determining whether or not to show the Unsaved Changes icon:
values => { target_id => 1, alt => "test image", title => "", width => "2000", height => "500", }
And this for the current ImageItem:
values => { alt => "test image", title => "", target_id => 1, }
Because there's no height or width set on the current ImageItem and it isn't possible to set these values by default, any paragraph with an image upload field will always show as having unsaved changes. I'm not really sure what should be done to fix this, because some people might have the image upload field set up to expose the width and height for users to change, in which case this difference becomes important. If you don't allow users to change the width and height in the field, however, these values should be ignored somehow.
- π¬π§United Kingdom JennyDumitrescu
I can confirm that this is still an issue on the newer (marked 'stable' version) of Paragraphs widget. We have had this issue raised where a user did the same approach as above (added a paragraph that contained an image field, added the image, and on collapse of the paragraph to continue their work, got the alert that they had unsaved content). This produced confusion in our case to the user due to the fact the only way to then save is to save to avoid the message, is to save the whole page rather than being able to save a paragraph alone to remove the error.