Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Group fields - unable to sort/drag & unable to remove/delete the 1st item #1483

Open
paolosax opened this issue Jan 13, 2023 · 7 comments
Open

Comments

@paolosax
Copy link

Describe the bug

I'm having issues on repeater/group fields, as now it seems that I can't sort/order each single fields groups, and also now I cannot remove the 1st group item

Steps to reproduce (I have confirmed I can reproduce this issue on the develop branch):

--

Possible Solution

--

Possible Solution's Risk Level

--

Screenshots

--

CMB2 Field Registration Code:

$features = new_cmb2_box(array(
    'id'                => PREFIX . 'features',
    'title'             => esc_html__('Features section', 'my-slug'),
    'object_types'      => array('my-cpt-slug'),
    'show_in_rest'      => true,
    'context'           => 'normal',
    'priority'          => 'high',
    'closed'            => true,
));
$cards = $features ->add_field(array(
    'id'          => PREFIX . 'features_cards',
    'type'        => 'group',
    'repeatable'  => true, // use false if you want non-repeatable group
    'options'     => array(
        'group_title'       => __('Card {#}', 'my-slug'), // since version 1.1.4, {#} gets replaced by row number
        'add_button'        => __('Add another feature', 'my-slug'),
        'remove_button'     => __('Remove feature', my-slug'),
        'sortable'          => true,
        'closed'         => true, // true to have the groups closed by default
        'remove_confirm' => esc_html__('Are you sure you want to remove?', 'my-slug'), // Performs confirmation before removing group.
    ),
));
$features ->add_group_field($cards , array(
    'id'   => PREFIX . 'features_card_image',
    'name' => esc_html__('Image', 'my-slug'),
    'desc' => '',
    'type' => 'file_list',
    'preview_size' => array(160, 90), // Default: array( 50, 50 )
    'query_args' => array('type' => 'image'), // Only images attachment
    'options' => array(
         'url' => false, // Hide the text input for the url
     ),
));

[other few text fields]

Your Environment

Browser name and version: Chrome
Operating System and version (desktop or mobile): Windows11

Additional context

Add any other context about the problem here.

@tw2113
Copy link
Contributor

tw2113 commented Jan 13, 2023

Can you open your browser's developer console and observe if there's any errors occurring at the javascript level?

Also is this with classic or block editor where you're seeing it?

@paolosax
Copy link
Author

Hello Michael - nope, no js errors in console (except some jquery migrate warnings).
And yes, block editor is enabled...

@tw2113
Copy link
Contributor

tw2113 commented Jan 13, 2023

Will try to test/confirm soon. I believe the inability to remove ALL is sort of intentional, even if empty. However I could be wrong with intent there.

@paolosax
Copy link
Author

As far as I know (ie: at least for what I learned using CMB2 quite often), the Group field will always have at least on item, but when you try to delete it it just delete the content of its inner fields... and that's fine. But what I experience now is that is not possible to remove it at all (meaning, remove the content of a single Group field). Weird...

@tw2113
Copy link
Contributor

tw2113 commented Jan 14, 2023

I know in the original issue there's a lot of the boilerplate GitHub issue content still in place, but I want to confirm if you have actually tested with the develop branch from GH here? Asking because I believe 920200a may fix this as it was a very similar issue.

@paolosax
Copy link
Author

Yep, it seems that this solve the "1st item delete" issue.
What I miss now is the "sortable" feature that still doesn't work.
But now I've the doubt that I'm not working using the right CMB2 version.
I mean: my Composer require is "cmb2/cmb2": "^2.10.1" (not "dev-develop")

@tw2113
Copy link
Contributor

tw2113 commented Jan 16, 2023

Correct, that require statement is based on the tagged versions and 2.10.1 is our most recent tag. Would not be pulling in changes in the develop branch. Not sure how to potentially do that via composer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants