The States API does not execute condition at first display when no default value is setted in field and select field has option #multiple = TRUE or #size.

Steps to reproduce:
- Create two fields in a form with the following code:

  $form['dependee'] = array(
    '#type' => 'select',
    '#options' => array(
      'a' => 'Option A',
      'b' => 'Option B',
      'c' => 'Option C',
    '#size' => 3,

  $form['dependent'] = array(
    '#type' => 'textfield',
    '#states' => array(
      'visible' => array(
        'select[name="dependee"]' => array('value' => array('a')),

I try to fix this adding $this->reevaluate() at the end of states.Dependent.prototype.initializeDependee. This works in browser, but writing tests with mink fail.

Tests should be covered by #2702233: Add Javascript tests for Form API's #states and this issue has been found working on #1149078: States API doesn't work with multiple select fields


GoZ created an issue. See original summary.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.