How to handle content_attributes

Created on 14 March 2023, over 1 year ago
Updated 4 June 2023, about 1 year ago

Problem/Motivation

I've been testing cl_server with storybook and sdc module, attempting to develop a story for πŸ“Œ Create new SDC component for Olivero (header-search) Needs work . The component expects a content_attributes array that it can add the data-drupal-selector to. I think ultimately the component should be refactored to not required that, but in the meantime it seems we should be able to support it.

Steps to reproduce

* Install SDC
* Set up cl_server with storybook
* Apply patch from #3347736
* Add the following to header-search-wide.stories.yml

title: Core/Olivero/Header Search Wide
stories:
  - name: 1. Default
    args:
      label: "Does this work"
      content_attributes: {}

Note the class and data attributes are not added and the javascript fails.

Proposed resolution

Β―\_(ツ)_/Β―

Remaining tasks

User interface changes

API changes

Data model changes

πŸ’¬ Support request
Status

Fixed

Version

2.0

Component

Code

Created by

πŸ‡¦πŸ‡ΊAustralia mstrelan

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

Comments & Activities

  • Issue created by @mstrelan
  • πŸ‡¦πŸ‡ΊAustralia mstrelan

    Not sure but this might be better suited for sdc_examples module.

  • e0ipso Can Picafort

    Storybook only supports basic data types for their knobs and controls. The content attributes is a PHP object in that component.

    One potential solution is to make the input an object, and the create the attributes inside the component via Twig's create_attribute.

    Another solution is to be more expressive about the kind of attributes you need and define each one of them separately.

    In any case, there is nothing we can do to add support from here.

  • Status changed to Fixed about 1 year ago
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.69.0 2024