New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Duplicate streamfield block duplicates UUID #7712
Comments
To add to this, I tried to debug a bit and I placed a console.log in this file: https://github.com/wagtail/wagtail/blob/main/client/src/components/StreamField/blocks/StreamBlock.js#L294 It appears that the // console.log(childState)
{
"type": "simple_question",
"value": {
"extended_answer": {
"body": [
{
"type": "text",
"value": "{\"blocks\":[{\"key\":\"kpdv3\",\"text\":\"coucou\",\"type\":\"unstyled\",\"depth\":0,\"inlineStyleRanges\":[],\"entityRanges\":[],\"data\":{}}],\"entityMap\":{}}",
"id": "f076404d-f25a-4199-9aab-a668151fae31"
}
]
}
},
"id": null
} |
I tried to fix this @gasman but I am very new to StreamField JavaScript's architecture. From my point of view, it seems to work (ids are properly removed, and then added server side). Let me know if you are happy with these changes, I will cleanup the PR and write a few tests. |
Just a note that this is still an issue in |
Issue Summary
I noticed streamfield's blocks uuid can be not unique.
It can be an issue, in my case in a headless setup, I cache blocks based on their UUIDs.
Steps to Reproduce
For example, let's consider a streamfield, containing a structblock, containing a streamblock.
Duplicating an instance of this structblock, with existing streamblocks, cause the nested streamblock UUIDs to remain identical to the original ones
I created an example repo here https://github.com/fabienheureux/wagtail-duplicate-streamfield-uuid
git clone https://github.com/fabienheureux/wagtail-duplicate-streamfield-uuid
./manage.py runserver
./manage.py shell
from home.models import HomePage
print(HomePage.objects.first().blocks.raw_data)
➡️ The body's UUIDs are the same
How to reproduce from Wagtail admin
Technical details
The text was updated successfully, but these errors were encountered: