kirki icon indicating copy to clipboard operation
kirki copied to clipboard

Strange multicheck behavior

Open peterhadorn opened this issue 11 years ago • 12 comments

I noticed some strange behavior today on multicheck fields - e.g. when one option is clicked/selected another option automatically gets selected too even though it was not clicked. Similarly when an option is deslected other options get deselected too. It's a minor issue and it's possible to correct the selections / deselections, but it doesn't feel right UX-wise? Not sure if this has been happening already before 0.7.

peterhadorn avatar Mar 15 '15 16:03 peterhadorn

I don't think I've seen this before... Can you please paste here the code you're using to add the multiselect field you're using? Are the settings saved ok? Or are they saved messed-up like they are being displayed for you?

aristath avatar Mar 15 '15 16:03 aristath

The settings are saved correctly, that's why it's just a minor issue. This is an example I use:

if ( ! function_exists( 'swibu_smsharing_setting' ) ) : function swibu_smsharing_setting( $controls ) { $controls[] = array( 'type' => 'multicheck', 'settings' => 'social_sharing', 'label' => __( 'Social Sharing', 'swibu' ), 'help' => __( 'Please select the options you would like to enable for social sharing.', 'swibu' ), 'section' => 'social', 'default' => '', 'priority' => 1, 'choices' => array( 'option_1' => __( 'Facebook', 'swibu' ), 'option_2' => __( 'Twitter', 'swibu' ), 'option_3' => __( 'LinkedIn', 'swibu' ), 'option_4' => __( 'Google+', 'swibu' ), 'option_5' => __( 'Pinterest', 'swibu' ), 'option_6' => __( 'Email', 'swibu' ), ), ); return $controls; } endif; add_filter( 'kirki/controls', 'swibu_smsharing_setting' );

peterhadorn avatar Mar 15 '15 16:03 peterhadorn

hmmmm... can you try using a sortable control and let me know if you're still having the same issues there? As a matter of fact I think it may even be better for you as that way your users will also be able to rearrange them! ;)

aristath avatar Mar 15 '15 17:03 aristath

I just did, it works fine for the social sharing options pasted above! Strangely, this basically identical code results in errors:

if ( ! function_exists( 'swibu_htr_setting' ) ) : function swibu_htr_setting( $controls ) { $controls[] = array( 'type' => 'sortable', 'settings' => 'headertr_display', 'label' => __( 'Header Top Right Settings', 'swibu' ), 'help' => __( 'Please choose what you would like to display in the top right corner of the header.', 'swibu' ), 'section' => 'header', 'default' => '', 'priority' => 1, 'choices' => array( 'option_1' => __( 'Phone Number', 'swibu' ), 'option_2' => __( 'Email Address', 'swibu' ), 'option_3' => __( 'Social Icons', 'swibu' ), ), ); return $controls; } endif; add_filter( 'kirki/controls', 'swibu_htr_setting' );

the errors i get:

    Warning: Invalid argument supplied for foreach() in C:\__dev\swibu.dev\wp-content\themes\swibu\lib\plugins\kirki\includes\controls\class-kirki-customize-sortable-control.php on line 40

    Warning: array_diff(): Argument #2 is not an array in C:\__dev\swibu.dev\wp-content\themes\swibu\lib\plugins\kirki\includes\controls\class-kirki-customize-sortable-control.php on line 43

    Warning: Invalid argument supplied for foreach() in C:\__dev\swibu.dev\wp-content\themes\swibu\lib\plugins\kirki\includes\controls\class-kirki-customize-sortable-control.php on line 44

When I replace sortable with multicheck it works fine, with the caveats described above. Don't know if I'm overlooking something simple?

Also, is there a way to set all sortable options by default to deselected?

peterhadorn avatar Mar 16 '15 16:03 peterhadorn

Hey there!

Can you please try using the develop branch and let me know if you're still having this issue there?

aristath avatar Mar 26 '15 21:03 aristath

still persists but some other bugs are fixed :)

peterhadorn avatar Mar 27 '15 16:03 peterhadorn

Hello again!

Using the develop branch I can't replicate the issue you're having with multicheck controls... The warnings you're getting when using the sortble control are probably because the default value there has to be defined as an array. :)

aristath avatar Mar 28 '15 14:03 aristath

@peterhadorn Hey there!

Can you please try the new "develop" branch? I'm still unable to replicate this issue so I don't know what's causing it on your end...

aristath avatar Apr 02 '15 07:04 aristath

I'll upgrade to 0.8.4 and check if I can reproduce it in all browsers, will let you know asap

peterhadorn avatar Apr 06 '15 16:04 peterhadorn

I updated and checked, this behavior still happens but only in Firefox. In all the other browsers it's fine. Maybe you can check if you can reproduce it there. But either way you can close this issue as it's extremely minor.

Thanks a lot for all your great work, it feels like you're really taking off with Kirki now :)

peterhadorn avatar Apr 08 '15 00:04 peterhadorn

@peterhadorn I just checked this with the master branch & couldn't replicate this one anymore.

aristath avatar Jun 20 '15 15:06 aristath

This turned out to be a firefox bug so I'll go ahead and close it. :+1: Hopefully they'll fix it soon enough.

aristath avatar Jul 06 '15 16:07 aristath