diff -u b/core/modules/taxonomy/src/ContextProvider/TermRouteContext.php b/core/modules/taxonomy/src/ContextProvider/TermRouteContext.php --- b/core/modules/taxonomy/src/ContextProvider/TermRouteContext.php +++ b/core/modules/taxonomy/src/ContextProvider/TermRouteContext.php @@ -9,6 +9,7 @@ use Drupal\Core\Plugin\Context\ContextProviderInterface; use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\StringTranslation\StringTranslationTrait; +use Drupal\taxonomy\Entity\Term; /** * Sets the current taxonomy term as a context on taxonomy term routes. @@ -46,6 +47,10 @@ $value = $term; } } + elseif ($this->routeMatch->getRouteName() == 'entity.taxonomy_term.add_form') { + $vocabulary = $this->routeMatch->getParameter('taxonomy_vocabulary'); + $value = Term::create(['vid' => $vocabulary->id()]); + } $cacheability = new CacheableMetadata(); $cacheability->setCacheContexts(['route']);