summaryrefslogtreecommitdiffstats
path: root/core/lib
diff options
context:
space:
mode:
authorAlex Pott2018-12-12 13:11:27 (GMT)
committerAlex Pott2018-12-12 13:11:36 (GMT)
commitc490e4029c0400b51c7a337c82a1085a8143dfc1 (patch)
tree8b581f3b9687ae64e673aed00a14eaed900a1cd3 /core/lib
parent4047cb0e27e07f4eb92b3b7533a62a5ef48ceb4c (diff)
Issue #2809305 by Upchuk, Pavan B S, Jo Fitzgerald, tim.plunkett, Berdir: Block Context assignment form element shows even if no options are availableHEAD8.6.x
(cherry picked from commit 55f13aacb5a348c5db49042d2abca04bc126eda4)
Diffstat (limited to 'core/lib')
-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]),