Layout Builder shouldn't use the default value to determine whether a field has a value or not

Created on 10 June 2024, 10 months ago
Updated 11 June 2024, 10 months ago

Problem/Motivation

This workaround was initially introduced in #3119786: Default values are not displayed for image fields placed in Layout Builder β†’ and added specifically for the image field type.

The default value specified in the field type is typically only used for new entities created within the form display, and not the view display, since it simply provides a default value (which can be deleted if the field is not required).

The image field type is one of the few exceptions which attempts to populate and render a field value even if it actually flags itself as empty.

Attempting to support this image-specific edge case has caused a knock-on effect affecting other fields, and as long as they have a default value specified, then if the field is set to display the title, then the title will always be shown regardless of if the underlying field is empty which shouldn't be the case.

Steps to reproduce

  1. Add a simple field with a default field value to a content type.
  2. Create a piece of content with that field empty.
  3. Add that field block in Layout Builder (with the "Display title" option ticked), and it'll show the layout builder's field title on the front-end even if the content doesn't have a value for it

Proposed resolution

Following options are available:

Remaining tasks

Discussion/PR.

User interface changes

TBD

API changes

TBD

Data model changes

TBD

Release notes snippet

TBD

πŸ› Bug report
Status

Needs work

Version

11.0 πŸ”₯

Component
Layout builder  β†’

Last updated about 1 hour ago

Created by

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024