Closed (fixed)
Project:
Experience Builder
Component:
Page builder
Priority:
Critical
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
21 Aug 2024 at 12:37 UTC
Updated:
12 Sep 2024 at 19:49 UTC
Jump to comment: Most recent, Most recent file


Comments
Comment #2
wim leers#3468049: Cannot place or drag child components landed.
Comment #4
wim leersPaired with @jessebaker, he let me know what's needed:
<div class="sortable-list" data-xb-uuid="%s" data-xb-type="%s"></div>for it to be presented as a slot in the UIOn it.
Comment #5
wim leersSDC default slot value woes
Turns out that SDC does not support:
[#slots][$slot_name] = []→ you'll get:Drupal\Core\Render\Component\Exception\InvalidComponentDataException: Unable to render component "experience_builder:two_column". A render array or a scalar is expected for the slot "column_one" when using the render element with the "#slots" property in Drupal\Core\Render\Element\ComponentElement->generateComponentTemplate() (line 118 of core/lib/Drupal/Core/Render/Element/ComponentElement.php).[$slots[$slot_name] = [#prefix => …, #suffix => …]→ you'll get only the prefix + suffixBut it does support not specifying any value at all for a slot, then it'll happily use the default.
IOW: I cannot wrap the default value of a slot (using
#prefix+#suffix) — doing so causes the default value to disappear 😬Investigation
So I investigated, to understand how to respect the SDC metadata for the
two-columncomponent that @ctrlADel added in #3446722: Introduce an example set of representative SDC components; transition from "component list" to "component tree":And discovered that
two-column.twigdu:… as you can see, the Twig template duplicates the sample content. That is where the default was coming from: from the Twig template not the SDC metadata! 😅
Now that I understand that, I can continue figuring out a solution.
Comment #6
wim leersTIL
#slotsAlter, while discovering #5.🐛 The test coverage in
\Drupal\KernelTests\Components\ComponentRenderTest::checkRenderElementAlters()is incorrect. It suggests you can choose which slot to alter, but you cannot: it alters the *value* of one slot at a time. (Unlike#propsAlter, which alters all props at the same time, just as the name + test logic suggests.)Hopefully that won't block this issue; because fixing that core bug would come with nasty BC break consequences.
Comment #7
wim leersUpstream core bug reported for #6: #3469933: `#propsAlter` alters all props simultaneously, `#slotsAlter` does not, despite its name and test coverage.
Comment #8
wim leersComment #9
jessebaker commentedI've given @balintbrews as much context about this issue as I can so hopefully he can assist with anything you need next week.
Comment #11
wim leersReady to be tested for confirmation that this makes the UI work as expected 😊
Comment #13
balintbrewsThis looks great, and it's very close! I noticed that you're able to drag the default content and place it even outside of its slot.
I pushed a fix for that, but we need to be able to target the default content somehow, so I propose that we wrap it in markup with a class named
xb-internal-component-example. (Feel free to rename it if you have a better idea or if you think we can simplify it.) Would you mind adjusting the rendering logic accordingly?I also added code to prevent inserting a component above the example — this way we avoid having the example content move up and down, which may incorrectly suggest that it would stay in place even after a component is added to that slot.
Comment #14
balintbrewsComment #15
wim leersGreat observation!
If I hack that together without writing code:
… then it looks like this:
… which makes me wonder: wouldn't it be better if:
Assuming you'd agree that's a good idea, I implemented something different instead: annotated the
div.sortable-listwrapper withdata-xb-slot-is-emptywhen it contains no components:WDYT? 😊
Comment #16
balintbrewsI like that idea! I played exactly with that last night after pushing my code, but deemed it too complex to do. I took a fresh look today and managed to implement it.
Towards the end of the gif you can see that we could tweak the sensitivity of the drop target boundaries, but I thought that could be part of a more comprehensive round of UI improvements, so I didn't spend time with that. The same goes for making the entire slot the "ghost element" and not only the fixed size that's used everywhere.
What do you think?
Comment #17
balintbrewsComment #18
wim leers+1!
But currently the
display: noneis causing a somewhat jarring experience IMHO: it causes the drop zone to disappear mid-drag-and-drop, which even makes it unreachable if you drop it back in the original location:Comment #19
balintbrewsOkay, this does need more work. I can see two problems:
The first problem can be somewhat temporarily mitigated by doing what I did initially: leaving the example in place and only allowing to drop something below it. If we do this, the second problem goes away for now. Then we can open a follow-up issue to address the problem properly, then re-introduce hiding the example content.
Or we can try to address everything in this issue. I'm happy either way! @Wim Leers, let me know how you prefer to proceed.
Comment #20
wim leersIf correct: I think that could be a fine follow-up issue. That's a weakness that this MR reveals, it doesn't introduce it?
i.e. I expected to be able to drag onto any part of the left columnin #18, instead of only the comparatively tiny target at the top.
display: noneif the drag-and-drop action was canceled (i.e. if the dragged sortable is restored to its original position).Comment #21
balintbrewsComment #22
balintbrewsComment #23
wim leersLGTM! I can't merge this though — it needs approval from both back-end and front-end folks 😊 Signaling that this is ready for final review by marking RTBC.
Comment #24
wim leersLet's first get @tedbow to review the changes to
ComponentTreeHydrated(Test).Comment #26
tedbowLooks good. I did my one suggestions
Comment #27
wim leersBack-end pieces are in place. Now needs front-end sign-off to land 🤓
Comment #28
tedbowLooks good. Thanks for the changes @Wim Leers
Comment #29
wim leersComment #30
bnjmnmReviewed FE only and approved as the FE person in the MR.
Comment #31
wim leers🥳 Thank you!
Comment #33
wim leersComment #34
kristen polRather than reopen this, Lauri said I should follow up in new issue so...
#3471085: Adding a component with slots does not register the slots as children