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

Blocks concertina'd shut by default

arctangent opened this issue · comments

We would like to be able to control which ones are open and which are closed by default

Yes, this is one of the upcoming features :)

Is it possible to have all open by default in todays version?

Since 1.0.0, released today, the default layout is SIMPLE, a layout closer to the old StreamField where there is no way to collapse blocks. Blocks can still be defined as using the COLLAPSIBLE layout by writing:

class YourBlock(CharBlock):
    def get_layout(self):
        return self.COLLAPSIBLE

That being said, you may want to keep COLLAPSIBLE blocks, but opened by default.

To do that, use this:

class YourBlock(CharBlock):
    def get_layout(self):
        return self.COLLAPSIBLE

    def get_definition(self):
        definition = super().get_definition()
        definition['closed'] = False
        return definition