themeum / kirki

Extending the customizer
https://kirki.org
MIT License
1.26k stars 328 forks source link

Sortable doesn’t work as active_callback #1686

Closed runnickrun closed 6 years ago

runnickrun commented 6 years ago

Issue description:

Showing / hiding item in sortable control has bugs when set as custom callback. On hiding dependent field show/hides only once, then nothing happens.

Version used:

(Did you try using the develop branch from github? There's a chance your issue has already been adressed there) 3.0.17

Using theme_mods or options?

theme_mods

Code to reproduce the issue (config + field(s))

Kirki::add_config( 'theme_config_id', array(
    'capability'    => 'edit_theme_options',
    'option_type'   => 'theme_mod',
) );

Kirki::add_field( 'theme_config_id', array(
    'type'        => 'sortable',
    'settings'    => 'my_setting',
    'label'       => __( 'This is the label', 'textdomain' ),
    'section'     => 'section_id',
    'default'     => array(
        'option3',
        'option1',
        'option4'
    ),
    'choices'     => array(
        'option1' => esc_attr__( 'Option 1', 'textdomain' ),
        'option2' => esc_attr__( 'Option 2', 'textdomain' ),
        'option3' => esc_attr__( 'Option 3', 'textdomain' ),
        'option4' => esc_attr__( 'Option 4', 'textdomain' ),
        'option5' => esc_attr__( 'Option 5', 'textdomain' ),
        'option6' => esc_attr__( 'Option 6', 'textdomain' ),
    ),
    'priority'    => 10,
) );

Kirki::add_field( 'theme_config_id', array(
    'type'            => 'toggle',
    'settings'        => 'my_setting_toggle',
    'label'           => __( 'Toggle that is dependent on sortable', 'textdomain' ),
    'section'         => 'section_id',
    'active_callback' => array(
        array(
            'setting'  => 'my_setting',
            'operator' => 'in',
            'value'    => 'option1' // array ('option1') also isn’t working
        ),
    ),
) );
aristath commented 6 years ago

fixed