Skip to content

Removing last group double confirm window #1427

Closed

Description

@milutinjaric
add_action( 'cmb2_admin_init', function(){
	
	$cmb = new_cmb2_box([
		'id'            => 'metabox_attachment',
		'title'         => 'TEst',
		'object_types'  => [ 'page' ], // Post type
		'priority'      => 'high',
		'show_names'    => true
	] );

	$group_field_id = $cmb->add_field( array(
		'id'          => 'wiki_test_repeat_group',
		'type'        => 'group',
		'description' => __( 'Generates reusable form entries', 'cmb2' ),
		'repeatable'  => true,
		'options'     => array(
			'group_title'       => __( 'Entry {#}', 'cmb2' ), 
			'add_button'        => __( 'Add Another Entry', 'cmb2' ),
			'remove_button'     => __( 'Remove Entry', 'cmb2' ),
			'sortable'          => true,
			'remove_confirm'    => esc_html__( 'Are you sure you want to remove this?', 'cmb2' ),
		),
	) );

	$cmb->add_group_field( $group_field_id, array(
		'name' => 'Entry Title 2',
		'id'   => 'subtitle',
		'type' => 'text',
		 'repeatable' => true,
		 'sortable' => true
	) );

});

Step 1.
Click on remove this entry or X button in upper left corner

Step 2.
Confirm dialog appears like expected. Click OK

Result
Another confirm dialog appears

Note.
When there are multiple groups remove dialog appears only once like it should. The issue happens only when one group remains

Activity

  1. tw2113 commented on Jun 1, 2021

    @tw2113
    Contributor

    @jtsternberg Seems like an extra entry is being either added or found and thus getting the prompt a second time.

  2. jtsternberg commented on Jun 3, 2021

    @jtsternberg
    Member

    Thank you for detailed testing steps. Fixed.

  3. added a commit that references this issue on Sep 28, 2021
    0e9ca56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions