diff --git a/core/lib/Drupal/Core/Plugin/ContextAwarePluginAssignmentTrait.php b/core/lib/Drupal/Core/Plugin/ContextAwarePluginAssignmentTrait.php index 299c209..746ad3d 100644 --- a/core/lib/Drupal/Core/Plugin/ContextAwarePluginAssignmentTrait.php +++ b/core/lib/Drupal/Core/Plugin/ContextAwarePluginAssignmentTrait.php @@ -67,6 +67,7 @@ protected function addContextAssignmentElement(ContextAwarePluginInterface $plug $element[$context_slot]['#empty_value'] = ''; } elseif (count($options) == 1) { + $element[$context_slot]['#default_value'] = key($options); $element[$context_slot]['#disabled'] = TRUE; $element[$context_slot]['#description'] .= '
' . $this->t('Note: This field cannot be changed because there is only one context item available and it is required.') . '
'; } diff --git a/core/modules/block/src/Tests/BlockLanguageTest.php b/core/modules/block/src/Tests/BlockLanguageTest.php index 265524f..13d7cf2 100644 --- a/core/modules/block/src/Tests/BlockLanguageTest.php +++ b/core/modules/block/src/Tests/BlockLanguageTest.php @@ -54,7 +54,8 @@ public function testLanguageBlockVisibility() { $this->drupalGet('admin/structure/block/add/system_powered_by_block' . '/' . $default_theme); $this->assertField('visibility[language][langcodes][en]', 'Language visibility field is visible.'); - $this->assertNoField('visibility[language][context_mapping][language]', 'Language type field is not visible.'); + $this->assertField('visibility[language][context_mapping][language]', 'Language type field is visible.'); + $this->assertEqual((string) $this->xpath('//select[@name="visibility[language][context_mapping][language]"]/@disabled')[0], 'disabled'); // Enable a standard block and set the visibility setting for one language. $edit = array(