Paragraph & Layout labels are not showing

Created on 15 June 2023, over 1 year ago
Updated 24 June 2024, 6 months ago

Problem/Motivation

Hi, I've got a problem with labels for paragraphs & layouts - they're not showing. I've checked Show Paragraph Labels & Show Layout Labels checkboxes in /admin/config/content/layout_paragraphs/labels... but I don't see any difference, no matter if they're checked or not. It would be great if labels are always visible, not only on hover... and I thought, these checkboxes can make this happen, but they don't.

It's related to other problem that I have... if you create a paragraph without any mandatory field, then it's really hard to edit such paragraph later on. It's being added, but it has like 0px height and it's very easy to omit it... or to save content without knowing that such paragraph is there. Please see attached screenshots.

I could handle this by adding extra CSS style, like .js-lpb-component {min-height: 40px;}, but it's still not perfect to me and I'm still missing labels.

Can you help?

Steps to reproduce

  1. Add Entity reference revisions field to the Page node.
  2. Set Layout Paragraphs form display widget for this field.
  3. Go to /admin/config/content/layout_paragraphs/labels, check Show Paragraph Labels & Show Layout Labels checkboxes and save configuration.
  4. Add a new Page, add some paragraph to this field and save the page.
  5. Go back to /admin/config/content/layout_paragraphs/labels, uncheck Show Paragraph Labels & Show Layout Labels checkboxes and save configuration.
  6. Go back to your page and notice there's no difference between previous and current version.
  7. Alternatively, create paragraph with only optional fields and add it to your page - then try to save it without filling any data, save the page and try to edit it afterwards.
๐Ÿ› Bug report
Status

Needs review

Version

2.0

Component

Code

Created by

๐Ÿ‡ต๐Ÿ‡ฑPoland tivi22

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

Merge Requests

Comments & Activities

  • Issue created by @tivi22
  • First commit to issue fork.
  • Open in Jenkins โ†’ Open on Drupal.org โ†’
    Core: 10.1.x + Environment: PHP 8.1 & MariaDB 10.3.22
    last update over 1 year ago
    55 pass
  • @sakthi_dev opened merge request.
  • Status changed to Needs review over 1 year ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia sakthi_dev

    Please review.

  • Status changed to Needs work over 1 year ago
  • ๐Ÿ‡ฆ๐Ÿ‡นAustria hudri Austria

    I think there is a conceptional problem here: These config settings are for admin widgets.

    hook_entity_view_alter() also affects frontend displays, the MR adds markup to all layout paragraphs, not just in widgets.

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom Vitor Faria

    Vitor Faria โ†’ made their first commit to this issueโ€™s fork.

  • Open on Drupal.org โ†’
    Core: 10.1.x + Environment: PHP 8.1 & MariaDB 10.3.22
    last update over 1 year ago
    Not currently mergeable.
  • Open in Jenkins โ†’ Open on Drupal.org โ†’
    Core: 10.1.x + Environment: PHP 8.1 & MariaDB 10.3.22
    last update over 1 year ago
    55 pass
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom Vitor Faria

    I have picked up the code from @sakthi_dev and changed it so that it only is executed if in an admin route (As @hudri suggested in his comment).

    Please review.

  • Status changed to Needs review over 1 year ago
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom Vitor Faria
  • Status changed to RTBC over 1 year ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States DamienMcKenna NH, USA

    This resolves the problem for me.

    FWIW I didn't know these options existed, so thank you!

  • ๐Ÿ‡ต๐Ÿ‡ฑPoland tivi22

    Thank you for the patch. Is it possible to make this label permanent/always visible (maybe in the top right corner, I think this feature worked in 1.x version)? In my case, the label displays only once and when I save a paragraph, it disappears (even when I don't fill any field).

  • ๐Ÿ‡ต๐Ÿ‡ฑPoland tivi22

    Yep, I've just installed Layout Paragraphs module in ver. 1.0.0 and it works very well. Please, take a look at scr. Is it possible to restore this feature?

  • ๐Ÿ‡ต๐Ÿ‡ฑPoland tivi22

    FYI I did a temporary solution and it works great in my case. All I did was providing custom CSS styles:

    /* Layouts */
    .js-lpb-component-list .lpb-layout:not(:first-child) {
      margin-top: 50px;
    }
    
    .lpb-layout > .field + .layout {
      margin-top: 20px;
    }
    
    /* Components */
    .js-lpb-component {
      margin-bottom: 10px;
      border: 1px dashed #999;
    }
    
    .js-lpb-component:not(.lpb-layout) > .field {
      padding: 5px 15px;
    }
    
    .js-lpb-component:not(.lpb-layout) > .lpb-controls + .field {
      border-top: 1px dashed #999;
    }
    
    .lp-builder:not(.is-navigating) .js-lpb-component:hover .js-lpb-region:hover,
    .lp-builder:not(.is-navigating) .js-lpb-component:focus-within .js-lpb-region:focus-within,
    .js-lpb-component:hover .js-lpb-region,
    .js-lpb-component:focus-within .js-lpb-region {
      outline-width: 0;
    }
    
    /* Controls */
    .lpb-controls {
      opacity: 1;
      z-index: 50;
    }
    
    .lpb-controls:hover,
    .lpb-controls:focus-within {
      z-index: 60;
    }
    
    .lpb-controls:not(.is-layout) {
      position: relative;
      box-shadow: none;
      background-color: #ededed;
    }
    
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom Vitor Faria

    @tivi22 I think that this should be seen as a separate issue as what you are describing is not what the issue description states.
    It is just my opinion but you should create a new ticket for that and propose there your solution.
    Also it might be a good idea to try and understand why the type labels are not showing instead of adding some CSS on top of it. Not saying that it might not be the solution but there might already be code that does what you want but is not because of some unknown bug.

  • Status changed to Needs work about 1 year ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States justin2pin

    Thanks for this. I think I'd rather see the paragraph labels added in the LayoutParagraphsBuilder::buildComponent method, which only runs when constructing the Layout Paragraphs builder interface, than in a hook that will run for every entity every time it is rendered. Flagging as needs work.

  • Open in Jenkins โ†’ Open on Drupal.org โ†’
    Core: 10.1.x + Environment: PHP 8.1 & MariaDB 10.3.22
    last update about 1 year ago
    55 pass
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia sakthi_dev

    Updated by addressing comment in #15. Please review.

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

    I noticed the code was only for show_paragraph_labels and not show_layout_labels. I've enhanced the code sakthi_dev did (will try to push to MR) that shows the layout when the setting is checked. Part of this is adding an additional check to existing code to make sure the paragraph is not a layout.

    Let me know if anyone has any questions and great to find this issue!

    -Nate

  • Open in Jenkins โ†’ Open on Drupal.org โ†’
    Core: 10.1.x + Environment: PHP 8.1 & MariaDB 10.3.22
    last update about 1 year ago
    55 pass
  • Status changed to Needs review about 1 year ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States nmillin

    Marking as Needs review since sakthi_dev addressed feedback in #15.

  • Status changed to Needs work about 1 year ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States justin2pin

    This is great - a few thoughts:

    - This needs tests.
    - Would also be helpful to have screenshots showing how this looks by default.
    - I'd rather use a <div> or <span> tag with a class than a strong tag.

  • Open in Jenkins โ†’ Open on Drupal.org โ†’
    Core: 10.1.x + Environment: PHP 8.1 & MariaDB 10.3.22
    last update about 1 year ago
    55 pass
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States nmillin

    Sure!

    Screenshots
    The default (per config/install/layout_paragraphs.settings.yml) is to not show the paragraph labels and not show the layout labels. I've included screenshots of how this looks with both labels showing and with a mouse hover.

    Div & a class
    I've pushed a commit to the MR doing this. Naming things is hard, so let me know if there should be any changes.

    Tests
    I'll poke at this. I'm guessing a new test in BuilderTest.php would be best. Let me know if this is the wrong direction.

    Thanks!

  • Open in Jenkins โ†’ Open on Drupal.org โ†’
    Core: 10.1.x + Environment: PHP 8.1 & MariaDB 10.3.22
    last update about 1 year ago
    28 pass, 6 fail
  • Open in Jenkins โ†’ Open on Drupal.org โ†’
    Core: 10.1.x + Environment: PHP 8.1 & MariaDB 10.3.22
    last update about 1 year ago
    48 pass, 2 fail
  • Status changed to Needs review about 1 year ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States nmillin

    sigh... the config change took forever to figure out why it wasn't working in the tests. I found https://www.drupal.org/node/2951441 โ†’ (paragraphs module) that is similar. drupal_flush_all_caches() is what is required for the config to work in the second test.

    I've added screenshots from the local test results I did. Removed the Needs Tests tag to reflect that tests were added and marking as needs review.

    Let me know if there should be any changes!

  • Open in Jenkins โ†’ Open on Drupal.org โ†’
    Core: 10.1.x + Environment: PHP 8.1 & MariaDB 10.3.22
    last update about 1 year ago
    48 pass, 2 fail
  • First commit to issue fork.
  • Open in Jenkins โ†’ Open on Drupal.org โ†’
    Core: 10.2.x + Environment: PHP 8.1 & MariaDB 10.3.22
    last update 6 months ago
    51 pass, 2 fail
  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia realityloop

    Re-rolled https://git.drupalcode.org/project/layout_paragraphs/-/merge_requests/132 so it applies to current dev and passes again

  • Pipeline finished with Failed
    6 months ago
    Total: 1022s
    #206375
  • Open in Jenkins โ†’ Open on Drupal.org โ†’
    Core: 10.2.x + Environment: php8.3_mysql8
    34:30
    31:21
    Running
  • Pipeline finished with Failed
    7 days ago
    Total: 262s
    #365690
  • Pipeline finished with Failed
    7 days ago
    Total: 266s
    #365691
  • Pipeline finished with Failed
    7 days ago
    Total: 272s
    #365692
  • Pipeline finished with Failed
    7 days ago
    Total: 271s
    #365693
Production build 0.71.5 2024