"show_empty" does not work in Layout Builder

Created on 11 June 2024, 16 days ago
Updated 21 June 2024, 7 days ago

Problem/Motivation

When show_empty is enabled, and the field is both empty and is being render in Layout Builder, the field never displays. I haven't been able to determine if this is an issue with Layout Builder, or can be resolved in the Office Hours code base.

Steps to reproduce

  1. Create an entity with an Office Hours field.
  2. Set up the entity's display settings is set to use Layout Builder
  3. Add the hours field to the layout.
  4. Set show_empty to TRUE.

Proposed resolution

Ideally, the field would still render just with every day marked as closed, like when the field isn't in Layout Builder.

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Postponed: needs info

Version

1.0

Component

Code - formatter

Created by

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

Comments & Activities

  • Issue created by @jeremyvii
  • 🇮🇳India kalpanajaiswal

    I tried to replicate the issue but it didn't reproduce.
    Drupal version: 10.2.7
    office_hours module version: 1.17.0

  • In order to replicate, all the hours must empty on the entity.

    Without Layout Builder.

    With Layout Builder

  • Status changed to Postponed: needs info 9 days ago
  • 🇳🇱Netherlands johnv

    This should not be possible. I guess all other settings are not used then, too. Please check that.
    Please check if the correct ViewMode is used.
    IN the code, you can see several references to layout_builder please grep them and test the behaviour.

  • I can confirm that I am using the correct view mode. After further investigation, this appears to be happening with any field in Layout Builder. In Drupal\layout_builder\Plugin\Block\FieldBlock::blockAccess, the selected field's isEmpty() method is checked, and if true, access to the block is forbidden. There appears to be an issue for the Drupal project to try to add a setting to allow the field to display, even if empty. It would be nice OfficeHoursItemList::isEmpty() returned false if show_empty is checked, but I can understand how that would be messy to implement.

    1. Drupal\layout_builder\Plugin\Block\FieldBlock::blockAccess
    2. 🐛 Formatters for empty fields do not render with layout builder enabled Needs work
  • 🇳🇱Netherlands johnv

    I tried to move the 'show_empty' into $items->isEmpty(), but the formatter settings are lost in the ItemList.
    I does not seem right to override the layout_builder code, even if it core.
    Also, it seems as I have a higher Drupal version then you, since in my 10.2.x system, #3119786: Default values are not displayed for image fields placed in Layout Builder is committed, removing the line you mention.
    Perhaps the problem is solved in a higher Drupal version?

Production build 0.69.0 2024