Loading core/modules/block/src/BlockForm.php +1 −2 Original line number Diff line number Diff line Loading @@ -186,7 +186,7 @@ public function form(array $form, FormStateInterface $form_state) { '#description' => $this->t('Select the region where this block should be displayed.'), '#default_value' => $region, '#required' => TRUE, '#options' => system_region_list($theme, REGIONS_VISIBLE), '#options' => system_region_list($form_state->getValue('theme', $theme), REGIONS_VISIBLE), '#prefix' => '<div id="edit-block-region-wrapper">', '#suffix' => '</div>', ]; Loading @@ -198,7 +198,6 @@ public function form(array $form, FormStateInterface $form_state) { * Handles switching the available regions based on the selected theme. */ public function themeSwitch($form, FormStateInterface $form_state) { $form['region']['#options'] = system_region_list($form_state->getValue('theme'), REGIONS_VISIBLE); return $form['region']; } Loading core/modules/block/tests/src/FunctionalJavascript/BlockAddTest.php 0 → 100644 +51 −0 Original line number Diff line number Diff line <?php namespace Drupal\Tests\block\FunctionalJavascript; use Drupal\FunctionalJavascriptTests\WebDriverTestBase; /** * Tests the JS functionality in the block add form. * * @group block */ class BlockAddTest extends WebDriverTestBase { /** * {@inheritdoc} */ protected static $modules = [ 'block', 'user', ]; /** * {@inheritdoc} */ protected $defaultTheme = 'stark'; /** * Tests the AJAX for the theme selector. */ public function testBlockAddThemeSelector() { \Drupal::service('theme_installer')->install(['seven']); $this->drupalLogin($this->drupalCreateUser([ 'administer blocks', ])); $this->drupalGet('admin/structure/block/add/system_powered_by_block'); $assert_session = $this->assertSession(); // Pick a theme with a region that does not exist in another theme. $assert_session->selectExists('Theme')->selectOption('seven'); $assert_session->assertWaitOnAjaxRequest(); $assert_session->selectExists('Region')->selectOption('pre_content'); $assert_session->assertWaitOnAjaxRequest(); // Switch to a theme that doesn't contain the region selected above. $assert_session->selectExists('Theme')->selectOption('stark'); $assert_session->assertWaitOnAjaxRequest(); $assert_session->pageTextNotContains('An illegal choice has been detected. Please contact the site administrator.'); $assert_session->optionExists('Region', '- Select -'); } } Loading
core/modules/block/src/BlockForm.php +1 −2 Original line number Diff line number Diff line Loading @@ -186,7 +186,7 @@ public function form(array $form, FormStateInterface $form_state) { '#description' => $this->t('Select the region where this block should be displayed.'), '#default_value' => $region, '#required' => TRUE, '#options' => system_region_list($theme, REGIONS_VISIBLE), '#options' => system_region_list($form_state->getValue('theme', $theme), REGIONS_VISIBLE), '#prefix' => '<div id="edit-block-region-wrapper">', '#suffix' => '</div>', ]; Loading @@ -198,7 +198,6 @@ public function form(array $form, FormStateInterface $form_state) { * Handles switching the available regions based on the selected theme. */ public function themeSwitch($form, FormStateInterface $form_state) { $form['region']['#options'] = system_region_list($form_state->getValue('theme'), REGIONS_VISIBLE); return $form['region']; } Loading
core/modules/block/tests/src/FunctionalJavascript/BlockAddTest.php 0 → 100644 +51 −0 Original line number Diff line number Diff line <?php namespace Drupal\Tests\block\FunctionalJavascript; use Drupal\FunctionalJavascriptTests\WebDriverTestBase; /** * Tests the JS functionality in the block add form. * * @group block */ class BlockAddTest extends WebDriverTestBase { /** * {@inheritdoc} */ protected static $modules = [ 'block', 'user', ]; /** * {@inheritdoc} */ protected $defaultTheme = 'stark'; /** * Tests the AJAX for the theme selector. */ public function testBlockAddThemeSelector() { \Drupal::service('theme_installer')->install(['seven']); $this->drupalLogin($this->drupalCreateUser([ 'administer blocks', ])); $this->drupalGet('admin/structure/block/add/system_powered_by_block'); $assert_session = $this->assertSession(); // Pick a theme with a region that does not exist in another theme. $assert_session->selectExists('Theme')->selectOption('seven'); $assert_session->assertWaitOnAjaxRequest(); $assert_session->selectExists('Region')->selectOption('pre_content'); $assert_session->assertWaitOnAjaxRequest(); // Switch to a theme that doesn't contain the region selected above. $assert_session->selectExists('Theme')->selectOption('stark'); $assert_session->assertWaitOnAjaxRequest(); $assert_session->pageTextNotContains('An illegal choice has been detected. Please contact the site administrator.'); $assert_session->optionExists('Region', '- Select -'); } }