Overview
Sometimes styles under preview can override the required Experience Builder foundational CSS. When a theme declares a component with a dependency, the dependency is loaded after the Experience Builder CSS.
For a concrete example, when display: flex is used to wrap a slot via an upstream dependency on a component, the result is that the drop-zone has a width of 0. This appears to happen because the default flex property for HTML elements is initial, which allows flex items to shrink, but not grow. The result seems to be that the nested .xb--sortable-slot-empty-placeholder element indeed shrinks to 0px wide.

Copy/Paste Example
example_flexbox_break.info.yml
name: "Example theme to showcase out of order CSS loading"
type: theme
core_version_requirement: ^11
base theme: false
regions:
content: "Content"
example_flexbox_break.libraries.yml
upstream-dependency:
css:
component:
css/upstream-dependency.css: {}
css/upstream-dependency.css
.example-flexbox-break {
display: flex;
}
components/example-flexbox-break.component.yml
'$schema': 'https://git.drupalcode.org/project/drupal/-/raw/HEAD/core/assets/schemas/v1/metadata.schema.json'
name: Example Flexbox Break
status: stable
group: Molecule/Example Flexbox Break
description: Example Flexbox Break
props:
type: object
properties:
dummy:
type: string
title: Dummy prop
slots:
content:
type: string
title: Content region
libraryOverrides:
dependencies:
- example_flexbox_break/upstream-dependency
example-flexbox-break.twig
<div class="example-flexbox-break">
{{ content }}
</div>
Proposed resolution
TBD - this is weird!
User interface changes
More working drop-zones 🥳
| Comment | File | Size | Author |
|---|---|---|---|
| #20 | its-fixed.png | 555.12 KB | luke.leber |
| #3 | flex-auto-applied.png | 1013.98 KB | bhogue |
| flexbox-break-after.png | 155.42 KB | luke.leber | |
| flexbox-break-before.png | 157.77 KB | luke.leber |
Issue fork experience_builder-3493841
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
bhogue commentedI'm going to take a stab at this.
Comment #3
bhogue commentedThis seems to work for me, but I'm not entirely sure what you're after and this is my first exposure at Experience Builder.
This is what I added to the CSS
Comment #4
luke.leberI think this one might be dependent on how https://www.drupal.org/project/experience_builder/issues/3491021 pans out.
Comment #5
luke.leberComment #6
luke.leberhttps://www.drupal.org/project/experience_builder/issues/3491021 has landed and this issue needs re-triaged. Self-assigning and will get around to this tomorrow between 8:30 and 5:00 ET.
Comment #7
luke.leberThis is certainly still an issue, except now the
.xb--sortable-slot-empty-placeholderclass doesn't specify a minimum width, and will collapse down to 0px wide if the parent element hasdisplay: flex.I think that the safest bet here is to give the
.xb--sortable-slot-empty-placeholdera width of 100%. The rationality here being that there should only ever be one empty placeholder per slot, right? As soon as a component is added, the placeholder goes away. I can't think of any reason why we wouldn't want the placeholder's drop-zone to be smaller than it could be!Comment #9
luke.leberComment #10
luke.leberI.S. update + NR
Comment #11
luke.leberComment #12
balintbrewsComment #13
luke.leberSetting back to Needs Work. Here's a slack chat to document where things are.
I think a deeper investigation is needed to see what exactly is going on.
Comment #14
luke.leberThis is a pretty gnarly issue. From what I can gather, these are the enabling criteria for the mix-up in CSS order...
1. The SDC must be provided by a theme
2. The SDC must define a
libraryOverridesthat adds a dependency.The result is that the dependency is loaded after the Experience Builder preview library 🤯. I'm not sure what the best way to share an example of this is.
Any suggestions?
Comment #15
luke.leberComment #16
luke.leberComment #17
luke.leberRe-titled, updated the I.S. with steps to reproduce and unassigned -- I have no idea where to even start to look now! As expected, the originally reported issue was only a manifestation of what seems to be a much more fundamental problem.
Comment #18
luke.leberComment #19
luke.leberWoo! Odds are the upstream issue is now fixed. Self-assigning for a re-test (tonight or tomorrow on the plane).
I still have a "broken" test case readily at hand.
Comment #20
luke.leberGreat news -- I'm going to close this one out as outdated. While this still results in a somewhat broken design system on my end, this is now able to be very easily resolved by adding a defensive display property that won't be clobbered by the Experience Builder scaffolding styles!
Thanks to everyone involved upstream.