summaryrefslogtreecommitdiffstats
path: root/core/lib/Drupal/Core
diff options
context:
space:
mode:
Diffstat (limited to 'core/lib/Drupal/Core')
-rw-r--r--core/lib/Drupal/Core/Plugin/ContextAwarePluginAssignmentTrait.php5
1 files changed, 4 insertions, 1 deletions
diff --git a/core/lib/Drupal/Core/Plugin/ContextAwarePluginAssignmentTrait.php b/core/lib/Drupal/Core/Plugin/ContextAwarePluginAssignmentTrait.php
index 31ff649..75cbc68 100644
--- a/core/lib/Drupal/Core/Plugin/ContextAwarePluginAssignmentTrait.php
+++ b/core/lib/Drupal/Core/Plugin/ContextAwarePluginAssignmentTrait.php
@@ -48,7 +48,10 @@ trait ContextAwarePluginAssignmentTrait {
];
}
- if (count($options) > 1 || !$definition->isRequired()) {
+ // Show the context selector only if there is more than 1 option to choose
+ // from. Also, show if there is a single option but the plugin does not
+ // require a context.
+ if (count($options) > 1 || (count($options) == 1 && !$definition->isRequired())) {
$assignments = $plugin->getContextMapping();
$element[$context_slot] = [
'#title' => $definition->getLabel() ?: $this->t('Select a @context value:', ['@context' => $context_slot]),