When a global region is empty, don't render HTML comment annotations into it

Created on 10 April 2025, about 1 month ago

Overview

As pointed out in https://www.drupal.org/project/experience_builder/issues/3512455#comment-16063301 ๐Ÿ“Œ Investigate drag-and-drop solution that removes the need to drop items into the preview iFrame Active there is an issue where the layout of a page can be negatively impacted by the insertion of our HTML comment annotations.

Proposed resolution

In the case that a region is exposed to XB but doesn't yet have any components in it, the HTML comments should not be added.

This is fine for the UX because users can never drag anything into empty regions - they are required to right click and choose "move to global region" before they can even focus on a region (at which point it's no longer empty!)

User interface changes

โœจ Feature request
Status

Active

Version

0.0

Component

Page builder

Created by

๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom jessebaker

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

Merge Requests

Comments & Activities

  • Issue created by @jessebaker
  • ๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ

    Conceptually related: ๐Ÿ› [Needs design] Previews of pages containing (dynamically) empty blocks are malformed Active .

    Is this referring to:

    • the outer <!-- xb-region-start-$region -->
    • or to the inner <!-- xb-region-content-start-$region -->
    • or both?

    I'm assuming both.

  • Merge request !885Resolve #3518606 "Empty region no comments" โ†’ (Merged) created by wim leers
  • ๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ
  • ๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ
  • Pipeline finished with Success
    about 1 month ago
    Total: 1575s
    #471148
  • Pipeline finished with Skipped
    about 1 month ago
    #471250
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom jessebaker

    Confirmed that exposing the Sidebar region in Olivero no longer breaks the page layout before anything has been added. Merged.

  • Pipeline finished with Success
    about 1 month ago
    Total: 1797s
    #471216
  • Noticed that there are empty regions marked by HTML comments. These empty region annotations arenโ€™t visible in the UI and donโ€™t affect the page layout, but they are still present in the markup and can be accessed via right-click in the UI.

    <!-- xb-region-start-content -->
    <!-- xb-region-end-content -->
    

    The reported issue specifically appears for the block-olivero-content block.

    Additionally, I observed other HTML comments appearing in the markup at the same time, such as:

    <!-- xb-region-content-end-primary_menu -->
    <!-- xb-region-end-primary_menu -->
    <!-- xb-region-start-secondary_menu -->
    

    These might be related to the same handling logic and could require a quick review to ensure consistency across regions.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States effulgentsia

    Thanks for testing this, @mayur-sose, and posting what your found!

    I believe both of your findings are "works as designed", so I'm setting this back to Fixed.

    <!-- xb-region-start-content -->
    <!-- xb-region-end-content -->
    

    This is about the content region, which is not a global region. Global regions are all the ones except for the one named "content". The reason it's okay (in fact, desired) for the content region to have those comments, even if otherwise empty, is those comments identify where you would drop something into, and the UI does allow dragging and dropping into the content region, even when the content region is empty, so we need those comments there. The reason this issue removed the comments from the global regions, is that unlike the content region, the UI does not allow dragging and dropping into an empty global region: to put something into an empty global region, you can only do it via the context menu (right click), not with drag-and-drop.

    <!-- xb-region-content-end-primary_menu -->
    <!-- xb-region-end-primary_menu -->
    

    Here, "content" is in the middle of the name, not the end of the name, so this isn't referring to the content region, but is referring to the content of the primary_menu region (yeah, it's confusing for the word "content" to mean different things in different contexts). So what this is saying is that the primary_menu region ends immediately after the content of that region ends. In other words, the primary_region doesn't have any wrapper markup around its content. That's perfectly normal.

    <!-- xb-region-end-primary_menu -->
    <!-- xb-region-start-secondary_menu -->
    

    This is saying that the secondary_menu region starts immediately after the primary_menu region ends. Also perfectly normal.

    So, all of the above cases are fine and expected, but great that you called them out so that we double checked to make sure. The ones we want to make sure aren't happening are:

    <!-- xb-region-start-ANYTHING_OTHER_THAN_"content" -->
    <!-- xb-region-end-ANYTHING_OTHER_THAN_"content" -->
    

    or

    <!-- xb-region-content-start-ANYTHING_OTHER_THAN_"content" -->
    <!-- xb-region-content-end-ANYTHING_OTHER_THAN_"content" -->
    

    If you find either of those, please re-open this.

  • ๐Ÿ‡ง๐Ÿ‡ชBelgium wim leers Ghent ๐Ÿ‡ง๐Ÿ‡ช๐Ÿ‡ช๐Ÿ‡บ

    #11++

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia nagwani
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024