Streamfield rendering breaks for blocks without an ID
solarissmoke opened this issue · comments
Wagtail doesn't require a StreamBlock
to have an ID until the point that it is saved in the database. This is helpful for things like pre-populating inital content into a streamfield, where you can initialise it with JSON such as:
json.dumps([
{'type': 'paragraph', 'value': '<p>This is a paragraph</p>'}
{'type': 'paragraph', 'value': '<p>This is another paragraph</p>'}
])
Doing so breaks the front-end handling of this field by wagtail-react-streamfield however - it looks like the JS expects an ID, and doesn't handle the case where there isn't one. The following works:
json.dumps([
{'type': 'paragraph', 'value': '<p>This is a paragraph</p>', 'id': '5670367b-d5fe-4d1f-8e20-2e3f585d0864'}
{'type': 'paragraph', 'value': '<p>This is another paragraph</p>', 'id': 'ce18d9bc-c0d6-4862-a3c3-756aa622309c'}
])
It would be good if it could handle the case where there is no block ID (as Wagtail does) for initial content - e.g., by just auto-generating one.
Weird, I’m pretty sure I handled that scenario. I will try to reproduce it.
OK, I identified the issue, it is fixed by c285a11.