Problem/Motivation
When using a view with a contextual filter on node ID, I witnessed different results of config being able to inject the context or not:
- Block Layout, placing the view block in a region: OK (native, unrelated to ui_patterns, tested for comparison)
- Block Layout, placing the view block in a slot: OK
- Layout Builder, placing the view block in a region: OK (native, unrelated to ui_patterns, tested for comparison)
- Layout Builder, placing the view block in a slot: OK
- Manage Display, placing the view block in a slot: KO
- Display Builder, placing the view block in a slot: KO
- Display Builder, placing the view block at root (but I guess regarding Display Builder structure there is no difference with previous case): KO
It is in app/core/lib/Drupal/Core/Block/BlockBase.php:
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$form = $this->traitBuildConfigurationForm($form, $form_state);
// Add context mapping UI form elements.
$contexts = $form_state->getTemporaryValue('gathered_contexts') ?: [];
$form['context_mapping'] = $this->addContextAssignmentElement($this, $contexts);
return $form;
}
The contexts needs to have been injected in the form state for $this->addContextAssignmentElement to generate the form elements for context mapping.
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| Capture d’écran du 2025-09-10 10-23-18.png | 111.3 KB | grimreaper | |
| Capture d’écran du 2025-09-10 10-22-34.png | 21.22 KB | grimreaper | |
| Capture d’écran du 2025-09-10 10-22-17.png | 44.93 KB | grimreaper | |
| Capture d’écran du 2025-09-10 10-24-47.png | 107.98 KB | grimreaper | |
| Capture d’écran du 2025-09-10 10-23-42.png | 46.34 KB | grimreaper |
Comments
Comment #2
just_like_good_vibeswe wait for #3540247: Tidy source contexts