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

Fields under tabs don't appear correctly with 'active_callback' #2507

Open
artkrsk opened this issue Jun 8, 2023 · 1 comment
Open

Fields under tabs don't appear correctly with 'active_callback' #2507

artkrsk opened this issue Jun 8, 2023 · 1 comment

Comments

@artkrsk
Copy link

artkrsk commented Jun 8, 2023

Issue description:

Hello, guys! Recently I've bought from you several extensions from Kirki Pro and would like to report a bug I've discovered while developing a new theme with a help of Kirki panels. This is related to "Tabs" extension.

When we have a registered field with active_callback under a tab, it doesn't appear correctly on the initial panels load. Consider the following example I've prepared for debugging:

Version used:

4.1.1

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

<?php

add_action( 'after_setup_theme', 'test_register_customizer_panels' );
function test_register_customizer_panels() {
  new \Kirki\Section(
    'section_id',
    array(
      'title' => esc_html__( 'Site Structure', 'kirki-pro' ),
      'tabs'  => array(
        'general' => array(
          'label' => esc_html__( 'General', 'kirki-pro' ),
        ),
        'design'  => array(
          'label' => esc_html__( 'Design', 'kirki-pro' ),
        ),
        'layout'  => array(
          'label' => esc_html__( 'Layout', 'kirki-pro' ),
        ),
      ),
    )
  );

  new \Kirki\Pro\Field\HeadlineToggle(
    array(
      'settings' => 'toggle_enabled',
      'section'  => 'section_id',
      'tab'      => 'general',
      'label'    => esc_html__( 'Test toggle', 'kirki-pro' ),
      'default'  => false,
    )
  );

  new \Kirki\Field\Slider(
    array(
      'settings'        => 'slider_control',
      'label'           => esc_html__( 'This one should be visible when "Test toggle" is ENABLED', 'kirki-pro' ),
      'section'         => 'section_id',
      'tab'             => 'design',
      'default'         => 1.5,
      'choices'         => array(
        'min'  => 0,
        'max'  => 3,
        'step' => 0.5,
      ),
      'active_callback' => array(
        array(
          'setting' => 'toggle_enabled',
          'value'   => true,
        ),
      ),
    )
  );

  new \Kirki\Field\Checkbox(
    array(
      'settings'        => 'test_checkbox_enabled',
      'section'         => 'section_id',
      'tab'             => 'layout',
      'label'           => esc_html__( 'This one should be visible only when "HeadlineToggle" is DISABLED.', 'kirki-pro' ),
      'default'         => false,
      'active_callback' => array(
        array(
          'setting' => 'toggle_enabled',
          'value'   => false,
        ),
      ),
    )
  );
}

I've recorded 2 short screencasts to better illustrate the problem:

1. "Test toggle" is initially DISABLED:
1. "Test toggle" is initially DISABLED

2. "Test toggle" is initially ENABLED:
2. "Test toggle" is initially ENABLED

In addition, the problem is gone when I do "Enable -> Disable -> Enable" on the toggle. After doing that the fields conditions in the other tabs refreshes and appear as expected.

Thank you.

@artkrsk
Copy link
Author

artkrsk commented Jul 20, 2023

Is this project still alive?

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

1 participant