Draggable Views breaks first column output if field contains a <drupal-placeholder> like a flag link

Created on 10 March 2022, about 3 years ago
Updated 22 December 2022, over 2 years ago

Problem/Motivation

If the first column in the views table contains output that uses a lazy builder () the placeholders are never rendered. This can result in a scenario where content that is displayed in the column normally gets broken when the draggableviews field is added to the table.

Current behavior - the output here is a teaser with flag links added to the view mode, but the flag links are not displayed:

Desired behavior - flag links are displayed:

Steps to reproduce

- Install Flag module, create a flag, add it to a node, and display the flag field as part of a node's teaser view mode
- Create a new draggable views view where the first column in the table is a "Content: Rendered entity" field that renders the node using the teaser view (which has the flag configured to display)

Example:

The table will show correctly, but the flag/unflag links will not show in the node's teaser. This is because the Flag module uses lazy builders to add flag links to the page. But, the code in draggableviews_preprocess_views_view_table() makes modifications to the render array that breaks the lazy builders and the flag links are never displayed.

Proposed resolution

When draggableviews_preprocess_views_view_table() alters the views table and adds an indent to the first column in the table it breaks the render array. It changes $variables['rows'][$key]['columns'][$first_column]['content'][0]['field_output']['#markup'] from a \Drupal\views\Render\ViewsRenderPipelineMarkup object to a string. Instead of calling render() to create a string and then using that string, we should instead add the indentation as a normal render array element that is a sibling of the 'field_output' element with a weight of something like -100 so that it renders first.

This will avoid using the call to render(); and allow the normal rendering pipeline to do it's job and ensure lazy builders / placeholders work.

πŸ› Bug report
Status

Needs review

Version

2.1

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States eojthebrave Minneapolis, MN

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • Status changed to RTBC 18 days ago
  • πŸ‡¦πŸ‡ΉAustria klausi πŸ‡¦πŸ‡Ή Vienna

    Thanks, looks good! Uploading stable patch file for composer patches.

Production build 0.71.5 2024