Skip to content
Snippets Groups Projects
Verified Commit b02bce4a authored by Théodore Biadala's avatar Théodore Biadala
Browse files

Issue #3386191 by phthlaap, sukr_s, Ozle, brunoalmeida, smustgrave, Ashley...

Issue #3386191 by phthlaap, sukr_s, Ozle, brunoalmeida, smustgrave, Ashley George, shiv_yadav, larowlan: #states not working correctly when built from a logical combination of multliple fields

(cherry picked from commit 5e2806f1)
parent 4792a5cc
Branches
Tags
4 merge requests!11958Issue #3490507 by alexpott, smustgrave: Fix bogus mocking in...,!11769Issue #3517987: Add option to contextual filters to encode slashes in query parameter.,!11185Issue #3477324 by andypost, alexpott: Fix usage of str_getcsv() and fgetcsv() for PHP 8.4,!9944Issue #3483353: Consider making the createCopy config action optionally fail...
Pipeline #198320 passed with warnings
Pipeline: drupal

#198337

    Pipeline: drupal

    #198332

      Pipeline: drupal

      #198326

        +1
        ......@@ -93,15 +93,16 @@
        */
        Drupal.behaviors.states = {
        attach(context, settings) {
        const $states = $(context).find('[data-drupal-states]');
        const il = $states.length;
        // Uses once to avoid duplicates if attach is called multiple times.
        const elements = once('states', '[data-drupal-states]', context);
        const il = elements.length;
        for (let i = 0; i < il; i++) {
        const config = JSON.parse(
        $states[i].getAttribute('data-drupal-states'),
        elements[i].getAttribute('data-drupal-states'),
        );
        Object.keys(config || {}).forEach((state) => {
        new states.Dependent({
        element: $($states[i]),
        element: $(elements[i]),
        state: states.State.sanitize(state),
        constraints: config[state],
        });
        ......
        ......@@ -730,6 +730,30 @@ public function buildForm(array $form, FormStateInterface $form_state) {
        '#title' => 'Enable textarea',
        ];
        $form['test_select_visible_dependence']['select_visible_1'] = [
        '#type' => 'select',
        '#title' => 'Select visible 1',
        '#options' => [0 => 0, 1 => 1],
        '#default_value' => 0,
        ];
        $form['test_select_visible_dependence']['select_visible_2'] = [
        '#type' => 'select',
        '#title' => 'Select visible 2',
        '#options' => [0 => 0, 1 => 1],
        '#default_value' => 0,
        ];
        $form['test_select_visible_dependence']['select_visible_3'] = [
        '#type' => 'select',
        '#title' => 'Select should show when 0 and 1 are selected',
        '#options' => [0 => 0, 1 => 1],
        '#states' => [
        'visible' => [
        ':input[name="select_visible_1"]' => ['value' => 0],
        ':input[name="select_visible_2"]' => ['value' => 1],
        ],
        ],
        ];
        return $form;
        }
        ......
        ......@@ -443,6 +443,15 @@ protected function doSelectTriggerTests() {
        $this->assertFalse($item_visible_value2->isVisible());
        $this->assertTrue($textfield_visible_value3->isVisible());
        $this->assertTrue($textfield_visible_value2_or_value3->isVisible());
        $this->container->get('module_installer')->install(['big_pipe']);
        $this->drupalGet('form-test/javascript-states-form');
        $select_visible_2 = $this->assertSession()->elementExists('css', 'select[name="select_visible_2"]');
        $select_visible_3 = $this->assertSession()->elementExists('css', 'select[name="select_visible_3"]');
        $this->assertFalse($select_visible_3->isVisible());
        $select_visible_2->setValue('1');
        $this->assertTrue($select_visible_3->isVisible());
        }
        /**
        ......
        0% Loading or .
        You are about to add 0 people to the discussion. Proceed with caution.
        Please register or to comment