area17 / twill

Twill is an open source CMS toolkit for Laravel that helps developers rapidly create a custom admin console that is intuitive, powerful and flexible. Chat with us on Discord at https://discord.gg/cnWk7EFv8R.
https://twillcms.com
Apache License 2.0
3.72k stars 568 forks source link

Editors with the same name override eachother's availableBlocks #2502

Open Tofandel opened 6 months ago

Tofandel commented 6 months ago

Description

When making a BlockEditor::make() with ->blocks() or ->excludedBlocks() if any other editor (eg one in a block on in the form, or two from different blocks) on the page has the same name, then the available blocks of both blocks are the same (one overrode the available blocks of the other)

Steps to reproduce

Create a few different blocks with nesting using

BlockEditor::make()
            ->name('description')->label(twillTrans('Description'))
            ->withoutSeparator()
            ->excludeBlocks(['text']);
BlockEditor::make()
            ->name('description')->label(twillTrans('Description'))
            ->withoutSeparator()
            ->excludeBlocks(['image']);

When you add one of this blocks into the other block, the nested block will show the wrong available blocks

This is due to this line which only uses the name of the block editor as a key https://github.com/area17/twill/blob/df08d1affdf489c953376e6b7612b8381b15c985/views/partials/form/_block_editor.blade.php#L11