Components without slots should not be available in Field Layout / DS

Created on 24 January 2025, 2 months ago

Problem/Motivation

When using a component as entity layout, slots are used to define regions to put fields in.
If a component has no slots, no region is available so no field can be enabled. Even if the component has filled props, Drupal will consider the render as empty and won't display the entity.

Steps to reproduce

  1. Enable Field Layout and UIP Layouts
  2. Create a SDC with only props
  3. Select and configure your SDC on one of your content types
  4. Try to display your content

Proposed resolution

Do not allow to select SDC without slots in the layouts.
If at least one component has been ignored, show a warning for the user to understand what's happening.

✨ Feature request
Status

Active

Version

2.0

Component

UI Patterns Layouts

Created by

πŸ‡«πŸ‡·France duaelfr Montpellier, France

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

Comments & Activities

  • Issue created by @duaelfr
  • πŸ‡ΊπŸ‡ΈUnited States dalemoore

    I disagree with this if I'm understanding what you're saying. It's entirely possible to use a component that renders only with props defined in the SDC and no slots if you're using web components. The rendering logic is instead in the JS/CSS/template of the web component. In this case all of the fields will be in the "disabled" region in Manage Display, and there would be no slot region(s), with the fields being mapped to props in the component only. If this capability is taken away I would need to quit using UI Patterns. I may be misunderstanding what you're saying, though!

  • πŸ‡«πŸ‡·France duaelfr Montpellier, France

    What I'm saying is that Drupal Core currently does not allow that. If all fields are disabled, the entity is not displayed.

    @pdureau dug a bit in this issue and figured out everything was happening inside \Drupal\field_layout\FieldLayoutBuilder::buildView() and \Drupal\field_layout\FieldLayoutBuilder::getFields().

  • πŸ‡ΊπŸ‡ΈUnited States dalemoore

    Okay, I'm using Display Suite rather than Field Layout, and haven't noticed a problem with it rendering slot-less SDCs as layout for my use. Maybe the issue is only there then, or we're using it differently. Just wanted to provide a different use case.

  • πŸ‡«πŸ‡·France pdureau Paris

    Hello Dualefr,

    We will see if we can do the change without being too specific to Field Layout.

    With UI Patterns, we are not targeting display building tools (Field Layout, Manage Dispaly, Layout Builder, Block Layout, Views...), but Core plugin types: Blocks, Formatters, Layouts...

    Of course, we wish to be compatible with all display builders, from Core and Contrib, so we will work on this subject, but I am not sure we will find a suitable fix.

  • πŸ‡«πŸ‡·France just_like_good_vibes PARIS

    It seems, the Field Layout Users should be careful to use only layouts with at least one region, and problem solved ?

  • πŸ‡«πŸ‡·France pdureau Paris

    too late fro 2.0.0

Production build 0.71.5 2024