drupal_block renders different html and attributes than block layout

Created on 17 December 2021, over 2 years ago
Updated 26 February 2023, over 1 year ago

Problem/Motivation

I noticed that drupal_block() does not render identical html and attributes as adding a block via block layouts. I wonder if this could have downstream impacts.

Steps to reproduce

1. Create a view
2. Add a block display
3. add exposed filters
4. turn ajax on.
5. Add block via {{ drupal_block('views_block:VIEW_MACHINE_NAME-VIEW-BLOCK-ID')}}
6. On a different page, add the block to a content region for a different node or content type. (Note: if you load the view block on the same page the exposed filters will conflict.
7. inspect the source for both blocks, notice class and id differences (note: use your browser's inspect source not dev tool source console. The latter cleans up html).

See below screen shot, the left is the twig template and the right is block layout. Here are the line items I find interesting:

  • 10
    • block layout has views-element-container and id while twig_tweak does not
  • 19
    • block layout has a div with no attributes while twig_tweak has the class from above and contextual-region

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Closed: cannot reproduce

Version

3.1

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States robpowell Boston

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.

  • πŸ‡·πŸ‡ΊRussia Chi

    Tried to reproduce with "Who is new" block in Drupal 10. Got identical markup. Something might have been changed since this issue was reported.

    Thank you.

Production build 0.69.0 2024