Problem/Motivation
The node variable is provided by template_preprocess_page, but it's only available for the canonical page. This is prone to bugs. For example, in Umami the page title is displayed twice in the node preview page because of this.
Proposed resolution
Make node variable available in page.html.twig on the preview page.
Remaining tasks
User interface changes
Before

After

API changes
node variable is not available in page.html.twig on the preview pages like it is on canonical pages.
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | Screen Shot 2023-02-18 at 1.44.51 PM.png | 1.99 MB | smustgrave |
| #4 | Screen Shot 2023-02-18 at 1.44.44 PM.png | 1.64 MB | smustgrave |
| #2 | 3342891-2.patch | 1.33 KB | lauriii |
Comments
Comment #2
lauriiiComment #3
lauriiiTagging this with Field UX even though this is not directly related to Field UI because this is still related to the user flow of configuring a content type.
Comment #4
smustgrave commentedConfirmed the issue on Umani demo.
Patch fixes the issue
Added screenshots to issue summary to show before/after
Comment #5
andy-blum+1 RTBC
Discussed with @laurii in slack the idea of adding a check of
\Drupal::routeMatch()->getParameter('node_revision')to ensure revision pages also get the node object, but it seems the node_revision parameter is always accompanied by the node parameter. Ultimately decided checks for node and node_preview cover all use cases.Comment #6
catchI think we should be trying to deprecate this rather than using it more widely. Why is it happening in template_preprocess_page() and not node_preprocess_page(), and/or why isn't it generic for entity types - if it's really needed at all. Having said that, maybe we want to commit this and look at it more widely in a different issue.
Comment #7
lauriii+1 for looking into deprecating the
nodevariable in a follow-up. FWIW, this is not adding additional usages, it just fixes the current, somewhat broken behavior. This also addresses usability impacting bug in Umami.Comment #8
bnjmnmI think removing
nodecould be disruptive to many sites, even if core doesn't use it heavily. However, I think a followup to discuss that should be created, and once that exists I'd be inclined to commit this 🙂Comment #9
lauriiiOpened follow-up for #6: #3345152: template_preprocess_page has a soft dependency on node module.
Comment #12
bnjmnmCommitted to 10.1.x, cherry-picked to 10.0.x. Will backport this non-disruptive fix to 9.5.x after confirming tests pass on that version.
Comment #13
bnjmnmCherry picked to 9.5.x as well.
Comment #14
luenemannCommit to 9.5.x is missing:
https://git.drupalcode.org/project/drupal/-/commits/9.5.x?search=Issue+%...
Comment #16
bnjmnmThanks @luenemann, looks like the push didn't take. This is up now.
Comment #18
quietone commentedPublished change record.