wagtail-deprecated / wagtail-react-streamfield

Powerful field for inserting multiple blocks with nesting. (NO LONGER MAINTAINED - See Wagtail 2.13 Release Notes)

Home Page:https://wagtail.github.io/react-streamfield/public/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Limitations with block naming

fpoulain opened this issue · comments

Hi,

Thank you for all your work. I use react-streamfield since about 18 month and I built some websites using exotic names containing '+' (plus) or '.' (dots).

It seems that theses names now break react streamfield.

Btw there is no advertising about it. Block._check_name don't refers to plus or dots.

Prior moving to wagtail-2.7, it worked (last known working version from pip : 1.3.5).

(Actually I am not sure if I should report this as a Wagtail bug.)

Ping ? (I am still not sure if I should report this as a Wagtail bug.)

Thanks for the report, I am going to investigate this, I don’t immediately know why it’s failing.

Could you elaborate more? I tested with Wagtail 2.9.3 & wagtail-react-streamfield 1.3.6, and didn’t face the issue with a rather tricky name, as you can see below. It correctly rendered and saved:
image
image

Hi,

Very thanks for your attention.

Unfortunately I am able to reproduce it in wagtail 2.7 and wagtail 2.9.

I started a repo here : https://forge.cliss21.org/fpoulain/issue54

After cloning it you can:

I could see the issue when using your project but… Your project is not using wagtail-react-streamfield!
The issue is really with Wagtail itself. It may seem that Wagtail now uses wagtail-react-streamfield, but it actually only uses the CSS of react-streamfield, adjusted to work with the old StreamField. Wagtail-react-streamfield is unfortunately still not yet in Wagtail due to long discussions and concerns regarding compatibility with a few third party blocks. For the record, we are arriving at a resolution for all these points, which will be documentation on how to migrate tricky third party block.

So I’m closing this issue for now, marking it as invalid, sorry :) Please open a Wagtail issue instead and reference this one. Thanks!

These names are invalid in vanilla Wagtail, as per the docs:

‘name’ is used to identify the block type within templates and the internal JSON representation (and should follow standard Python conventions for variable names: lower-case and underscores, no spaces)

But it works with wagtail-react-streamfield because it only uses UUIDs to identify field instances 😛

@BertrandBordage ok sorry, I have been confused. I started to migrate a project from wagtail 2.4 + wagtail-react-streamfield to wagtail 2.7. I thought the latter has included wagtail-react-streamfield.

@gasman Ok, so i was misled by Block._check_name which was too lazy. Is it useful to propose a patch making it more restrictive?

But it works with wagtail-react-streamfield because it only uses UUIDs to identify field instances stuck_out_tongue

And installing wagtail-react-streamfield hide my problem. Thanks for the hint.

@gasman Ok, so i was misled by Block._check_name which was too lazy. Is it useful to propose a patch making it more restrictive?

Sure, sounds good. I think it makes sense for Block._check_name to reject anything which is not valid as a python variable name (so, for example, it should reject any names with invalid symbols, but it should still allow uppercase).

ok; I will propose a PR.