Problem/Motivation

As a follow-up of #3612556: PageLayoutSource is sometimes not rendered.

We can't apply styles to PageLayoutSource.

Proposed resolution

Proposal 1: let's assume some source plugins don't handle attributes

PageLayoutSource is not the only source returning a renderable not compatible with #attributes, do we:

  • test the renderable on Display Builder side, and load the Style & Tokens panels only if compatible?
  • add a specific plugin attributes on UI Patterns side, and load the Style & Tokens panels only if compatible?

If we do something like that, we also need to remove content (a leftover of an intermediary state of #3612556: PageLayoutSource is sometimes not rendered, may be harmful) here:

$build['content'][$slot_id] = $slot;

Proposal 2: Make PageLayoutSource compatible with attributes

For example, by wrapping the page renderable:

    return [
      // `page` renderable doesn't accept #attributes, so let's wrap it up to
      // be able to apply styles and other dynamic attributes.
      '#type' => 'html_tag',
      '#tag' => 'div',
      'content' => $page,
    ];

However, this is not working with every themes:

  • UI suite DaisyUI: ✅ good layout rendering and styles correctly applied
  • UI suite Material: ✅ good layout rendering and styles correctly applied
  • UI suite DSFR: ✅ good layout rendering and styles correctly applied
  • UI suite Bootstrap: ❌ page renderable is not rendered
  • UI suite USWDS: ❌ page renderable is not rendered
  • bootstrap with I suite Bootstrap styles: ✅ good layout rendering and styles correctly applied
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

pdureau created an issue. See original summary.

mogtofu33’s picture

mogtofu33’s picture

Tested with UI Suite Bootstrap, the $build['content'][$slot_id] = $slot; works, but if you set style, then instead of applying to child it make it disappear.

So will pass a quick hotfix to dev for $build[$slot_id] = $slot;.

Note that current state is already better than beta5, as current beta5 simply render nothing. So hotfix is only for when a style is applied.

grimreaper’s picture

Assigned: pdureau » grimreaper

grimreaper’s picture

Assigned: grimreaper » Unassigned
Status: Active » Needs work
pdureau’s picture

Status: Needs work » Needs review

i will give a look

pdureau’s picture

Assigned: Unassigned » mogtofu33
Status: Needs review » Reviewed & tested by the community

Thanks for the patch @grimreaper, i have applied the changes from [ #3612556] and the results are good:

  • UI suite DaisyUI: ✅ good layout rendering and styles correctly applied
  • UI suite Material: ✅ good layout rendering and styles correctly applied
  • UI suite DSFR: ✅ good layout rendering and styles correctly applied
  • UI suite Bootstrap: ✅ good layout rendering and styles correctly applied
  • UI suite USWDS: ✅ good layout rendering and styles correctly applied

mogtofu33’s picture

Assigned: mogtofu33 » Unassigned
Status: Reviewed & tested by the community » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.