BUG - Group creates a new group entry upon edit & save (MB Blocks extension)
Support › MB Group › BUG - Group creates a new group entry upon edit & save (MB Blocks extension)Resolved
- This topic has 9 replies, 4 voices, and was last updated 5 months ago by
ambrdigital.
-
AuthorPosts
-
October 19, 2024 at 1:20 AM #46723
ambrdigital
ParticipantHey there!
We’ve come across a bug when using the Group extension with the MB Blocks extension.
Whenever we save or edit any field within a block, the group field creates an extra entry, even if we didn’t intend to. This happens whether it's a single group or a nested group, and it always adds a clone in the first position of all the groups with the block.
This issue is affecting all our sites using the Group extension with MB Blocks, and it's becoming a bit of a headache. We'd really appreciate a quick fix for this.
For reference, we’re on the latest versions:
Meta Box Version 5.10.2
Meta Box AIO Version 1.30.2Hope this helps! Let us know if you need any more details. 🙂
October 21, 2024 at 3:58 PM #46734BoatKung
ParticipantI just wanted to confirm that I’m experiencing the same issue.
October 21, 2024 at 10:04 PM #46738Peter
ModeratorHello Ambr,
Please export the field group to a JSON file and share it here with a screen record that illustrates the issue. I will check this on my demo site. You can follow the documentation to export the field group.
https://docs.metabox.io/extensions/meta-box-builder/#export--importOctober 21, 2024 at 10:06 PM #46739SHANDA
ParticipantI am having this issue with the tabs on this page https://opqic.org/omno/. Please share if you find a solution. I am seeing this issue on multiple client sites now.
October 21, 2024 at 10:52 PM #46741ambrdigital
ParticipantHi Peter,
We coded the block, I have added below the code of a test block that you can use to troubleshoot and test this bug, We reverted our Meta Box AIO plugin version to 1.30.0 and we do not get have the bug in this version. I suspect the bug is related to the plugin update with 1.30.1 - 2024-09-07 Fix issue with clone_empty_start, that woudl probably be a great place to start the investigation.
Appreciate you looking in to this, let me how if you need any thing else.
Cheers,
Anthonymeta-boxes__test-block.php
<div><?php add_filter( 'rwmb_meta_boxes', 'test_block_meta_boxes' ); function test_block_meta_boxes( $meta_boxes ) { $meta_boxes[] = [ 'title' => 'Test Block', 'id' => "test-block", 'type' => 'block', 'fields' => [ [ 'type' => 'heading', 'name' => 'Test Block', ], [ 'id' => "block_group", 'type' => 'group', 'clone' => true, 'max_clone' => 3, 'sort_clone' => true, 'collapsible' => true, 'save_state' => true, 'group_title' => 'Group {#}', 'add_button' => '+ Add Group', 'fields' => [ [ 'name' => 'Header', 'id' => "block_header", 'type' => 'textarea', 'rows' => 1 ], [ 'id' => "block_group_inner", 'type' => 'group', 'clone' => true, 'sort_clone' => true, 'collapsible' => true, 'save_state' => true, 'group_title' => 'Column {#}', 'add_button' => '+ Add Test', 'fields' => [ [ 'name' => 'Inner Header', 'id' => "block_inner_header", 'type' => 'textarea', 'rows' => 1 ] ] ], ], ], ], ]; return $meta_boxes; };</div>
block.json
<div>{ "$schema": "https://schemas.wp.org/trunk/block.json", "apiVersion": 3, "name": "meta-box/test-block", "title": "Test Block", "description": "The Test Block is a custom block that allows you to test the block editor.", "category": "common", "icon": "fas fa-truck-monster", "keywords": [ "test", "block", "test block" ], "supports": { "anchor":true }, "attributes": { "anchor":{ "type": "string" }, "g-block_group": { "type": "array" } }, "render": "file:./test-block.php" }</div>
.
text-block.php
<div><?php /** * @var array<string, mixed>[] $attributes The block attributes. * @var string $content The block default content. * @var \WP_Block $block The block instance. */ $blockName = "test_block"; $prefix = "block_"; $class = "mb-block_" . $blockName; $id = ( $blockName . '-' . $attributes['id'] ?? '' ); if ( ! empty( $attributes['anchor'] ) ) { $id = $attributes['anchor']; } if( is_admin() || (defined( 'REST_REQUEST' ) && REST_REQUEST && 'edit' === $_GET['context'])) { echo '<p>Test Block</p>'; } $group = $attributes["{$prefix}group"] ?? null; if( !empty($group)){ var_dump($group); foreach ( $group as $group_value ) { $header = isset( $group_value["{$prefix}header"] ) ? $group_value["{$prefix}header"] : null; $group_inner = isset( $group_value["{$prefix}group_inner"] ) ? $group_value["{$prefix}group_inner"] : null; ?> <div id="<?php echo $id; ?>" class="<?php echo $class ?> bg--blue"> <div class="container-fluid--small"> <div class="row"> <div class="col-12"> <?php if($header): ?> <h2><?php echo $header; ?></h2> <?php endif; ?> <?php if( !empty($group_inner)){ foreach ( $group_inner as $group_value ) { $inner_header = isset( $group_value["{$prefix}inner_header"] ) ? $group_value["{$prefix}inner_header"] : null; ?> <div class="col-12"> <p><?php echo $inner_header; ?></p> </div> <?php } ?> <?php } ?> </div> </div> </div> </div> <?php } }</div>
October 21, 2024 at 10:54 PM #46742ambrdigital
ParticipantHi Peter, minor correct in the block.json file.
<div>{ "$schema": "https://schemas.wp.org/trunk/block.json", "apiVersion": 3, "name": "meta-box/test-block", "title": "Test Block", "description": "The Test Block is a custom block that allows you to test the block editor.", "category": "common", "icon": "fas fa-truck-monster", "keywords": [ "test", "block", "test block" ], "supports": { "anchor":true }, "attributes": { "anchor":{ "type": "string" }, "block_group": { "type": "array" } }, "render": "file:./test-block.php" }</div>
October 21, 2024 at 11:37 PM #46743Peter
ModeratorHello,
Thanks for sharing, I can see the issue on the demo site. This has been escalated to the development team and we will work on this to fix the issue as soon as possible.
October 29, 2024 at 12:01 AM #46776SHANDA
ParticipantChecking on the status of this bug fix?
November 8, 2024 at 11:35 PM #46898Peter
ModeratorFYI, the fix for this issue is included in the new version of Meta Box AIO 1.30.5.
November 12, 2024 at 11:51 PM #46917ambrdigital
ParticipantThank you
-
AuthorPosts
- You must be logged in to reply to this topic.