Move child components to the slots of their parents and embed them directly in Drupal templates

Created on 12 August 2024, 3 months ago
Updated 27 August 2024, 3 months ago

Problem/Motivation

https://www.drupal.org/u/pdureau said on Drupal Slack:

One of the reasons why I am so loudly promoting the use of slots and the injection of children components "from the outside" instead of embedding/including components in templates is to avoid "prop drilling": adding props to the parent component only for injection in the child component. For example, a card component with such props:
button1_url
button1_text
button2_url
button2_text

- https://drupal.slack.com/archives/C4EDNHFGS/p1723278993225889?thread_ts=...

It makes sense to https://www.drupal.org/u/doxigo

Proposed resolution

  • Go through the component twig templates and identify embedded child components
  • Create slots for them and move the embed to the Drupal template(s) where parent templates are used

This would represent a significant change in the theme, perhaps we should start 7.x releases?

🌱 Plan
Status

Closed: works as designed

Version

6.0

Component

Code

Created by

🇨🇿Czech Republic milos.kroulik

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

Comments & Activities

  • Issue created by @milos.kroulik
  • Status changed to Closed: works as designed 3 months ago
  • It does make sense but not that much of an urgent issue that requires an action right away, props drilling isn't ideal but still gets you going a lot of times and it works fine as is in Radix, we can reconsider this at a later stage if needed, marking this as closed but will have it in mind if it comes to 6.0.x or the Tailwind version of Radix, thanks

Production build 0.71.5 2024