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

No ability to add streamfield items within an inline panel without min_num=1 #35

Closed stuartaccent closed 5 years ago

stuartaccent commented 5 years ago

Hi guys

I found a bug today, defining:

class MyPageFooItem(Orderable):
    page = ParentalKey(..., related_name='foos')
    content = StreamField([...])

    panels = [
        StreamFieldPanel('content'),
    ]

class MyPage(Page):
    ...
    content_panels = Page.content_panels + [
        InlinePanel('foos', label="Foos"),
    ]

renders no options to add any item from the streamfield within the inline panel. You just get a label Foos:. If you then oddly add min_num=1 to the inline they appear and you can happily add content:

class MyPage(Page):
    ...
    content_panels = Page.content_panels + [
        InlinePanel('foos', label="Foos", min_num=1),
    ]

Im guessing its prob a js thing in that with min_num=1 one will be on the page already.

Also adding a second inline via the button renders no content till you try to save it.

Cheers Stu

BertrandBordage commented 5 years ago

That’s a tough issue. I didn’t think about the inclusion of streamfields in inlines, I honestly never did that and didn’t even think it was possible!

Fortunately, this should be fixed by the huge rewrite I am currently doing with the guidance of Thibaud Colas here: https://github.com/noripyt/react-streamfield/issues/4 It should be fixed because we will no longer initialize StreamField the same way. They were initialized all at once on page load, now they will be initialized in inline scripts, so it should perfectly work with inlines :)

stuartaccent commented 5 years ago

Superb

BertrandBordage commented 5 years ago

Fixed by https://github.com/wagtail/wagtail/pull/4942/commits/73e01f2297380f9a93ea97d564e8057783946685, will be in a new version of wagtail-react-streamfield today.

BertrandBordage commented 5 years ago

Released in version 1.2.0.