WIP: Builder: Changing Controls outside of Repeater-Control, that are required for a Repeater-Control Field doesn't update state immediately

This is an old bug, but I thought I bring it up now.
Right now if we change a Control outside of the repeater-Control, that should change the visibility of certain fields inside that repeater-Control the visibility of those fields only changes after reopening the Repeater Item again. It would be a great UI improvement and less confusing if that display change would be instant.

Example Code:


    // MARK: Set Controls
    public function set_controls()
    {
        $this->controls['repeater'] = [
            'tab' => 'content',
            'label' => esc_html__('Repeat', 'bricks'),
            'type' => 'repeater',
            'titleProperty' => 'title',
            'selector' => "{$this->name}__item",
            'checkLoop'  => true,
            'placeholder' => esc_html__('List item', 'bricks'),
            'fields' => [
                'icon' => [
                    'label' => esc_html__('Icon', 'bricks'),
                    'type' => 'icon',
                    'required' => ['style', '=', 'icon'],
                ],
                'title' => [
                    'label' => esc_html__('Title', 'bricks'),
                    'type' => 'text',
                    'required' => ['type', '=', ['title', 'link', 'title-content', false]],
                ],
                'link' => [
                    'label' => esc_html__('Link', 'bricks'),
                    'type' => 'link',
                    'required' => ['type', '=', 'link'],
                ],
                'description' => [
                    'label' => esc_html__('Description', 'bricks'),
                    'type' => 'editor',
                    'required' => ['type', '=', ['content', 'title-content']],
                ],
            ],

        ];

        $this->controls = array_replace_recursive($this->controls, $this->get_loop_builder_controls());

        $this->controls['style'] = [
            'label' => esc_html__('Style', 'bricks'),
            'type' => 'select',
            'options' => [
                'default' => esc_html__('Default', 'bricks'),
                'icon' => esc_html__('Icon', 'bricks'),
            ],
            'inline' => true,
            'clearable' => true,
            'placeholder' => esc_html__('Default', 'bricks'),
        ];

        $this->controls['type'] = [
            'label' => esc_html__('Type', 'bricks'),
            'type' => 'select',
            'options' => [
                'title' => esc_html__('Only Title', 'uf-theme'),
                'link' => esc_html__('Title with Link', 'uf-theme'),
                'title-content' => esc_html__('Title with Content', 'uf-theme'),
                'content' => esc_html__('Only Content', 'uf-theme'),
            ],
            'inline' => true,
            'placeholder' => esc_html__('Only Title', 'uf-theme'),
        ];
}

Best Regards
Suat

Hey @UserfreundSuat,

thanks for the report. I’m not sure if this would count more as a improvement rather than a bug, but I was able to replicate it, and I’ve added it to our internal tracker.

Thank you,
Matej

1 Like