SDC componentMetadata does not take the right context when a component is extended

Created on 10 October 2023, about 1 year ago
Updated 18 June 2024, 5 months ago

Problem/Motivation

Using SDC there is a problem when a component extends from another and wants to use the componentMetadata object in order to, for instance, use the Component path information to load some images from the component's folder.

Steps to reproduce

As the sdc_examples module shows here, the problem comes when a component uses the extend inside their template expecting the files from that component to be loaded but instead the ones coming from the extended component end up showing.

Proposed resolution

I guess the componentMetadata object should get the right context depending the component which ends up being loaded.

As a workaround a twig block can be used from the extended component in order to apply the right componentMetadata information as the following example shows:

{% set metadata = componentMetadata %}
{% embed 'sdc_example:my-button--primary' %}
  {% block iconTypeBlock %}
    {{ source(metadata.path ~ '/img/' ~ iconType|default('power') ~ '.svg') }}
  {% endblock %}
{% endembed %}
πŸ› Bug report
Status

Active

Version

11.0 πŸ”₯

Component
single-directory componentsΒ  β†’

Last updated 3 days ago

Created by

πŸ‡ͺπŸ‡ΈSpain pakmanlh Barcelona

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024