wagtail-deprecated / wagtail-react-streamfield

Powerful field for inserting multiple blocks with nesting. (NO LONGER MAINTAINED - See Wagtail 2.13 Release Notes)
https://wagtail.github.io/react-streamfield/public/
BSD 3-Clause "New" or "Revised" License
74 stars 23 forks source link

new changes to stream field content is lost if a validation error occurred while saving #29

Closed AsankaL closed 5 years ago

AsankaL commented 5 years ago

I've created a custom ImageGalleryBlock and ImageGalleryItemBlock as follow.

class ImageGalleryBlock(StructBlock):
    image_list = ListBlock(ImageGalleryItemBlock(), label="Image Gallery")
    title = CharBlock(label="Gallery Title")

class ImageGalleryItemBlock(StructBlock):
    image = ImageChooserBlock()
    caption = CharBlock(required=False)

When I try to save and there is validation error in the one of these blocks, react-streamfield crashes.(e.g: trying to save without 'title' for ImageGalleryBlock) It shows Uncaught TypeError: Cannot read property 'split' of null in console.

BertrandBordage commented 5 years ago

I can confirm it, introduced recently by noripyt/react-streamfield@d76a986a536adf941563ac5e477c8f549c43730e & noripyt/react-streamfield@0ee27e093c4404d3a8058d6fcf911caa20aee886. I’m working on a fix.

BertrandBordage commented 5 years ago

Fixed by https://github.com/noripyt/react-streamfield/commit/9adafc927d81aa758273e27b831dcfd42af62f0c and released in 1.1.1.