Attributes id and styles get overwritten instead of being added to the existing one.

Created on 12 June 2024, 7 months ago
Updated 29 July 2024, 5 months ago

Problem/Motivation

When using some other module to attach other custom id,classes, styles to the attributes like layout_builder_backgrounds β†’ this module is overwriting those settings.

Steps to reproduce

Install layout_custom_section_classes β†’ and layout_builder_backgrounds β†’ .
Setup background color in layout_builder_background and then some custom style via layout_custom_section_classes. Background will be overwritten and only setting from layout_custom_section_classes will be used.

Proposed resolution

Use same approach as in .module file for custom classes.

Remaining tasks

Check if this change is enough for described problem.

πŸ› Bug report
Status

Needs review

Version

2.0

Component

Code

Created by

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

Merge Requests

Comments & Activities

  • Issue created by @windy-ux
  • Status changed to Needs work 7 months ago
  • πŸ‡ΈπŸ‡°Slovakia kaszarobert
    +    $variables["attributes"]["id"][] = $variables['settings']['custom_id'];
    

    I think "id" is usually a single value, not an array since the HTML id semantically should be single value without spaces, see https://www.w3schools.com/html/html_id.asp I'm afraid the best we can do is skipping this operation and not doing anything if id is an empty string.

    The style appending seems okay. Although I would strongly encourage everyone to write these styles in the theme's CSS for specific classes and set classes in layouts. It will be much more maintainable that way.

    Could you also do this style appending method in region attributes?

  • Thank you for mentioning the id. I removed that change so it is only one.

    I agree with the theme's CSS.

    "Could you also do this style appending method in region attributes?"
    Do you mean to change the implementation in the way that the styles are appended there as well, not overwritten?

  • πŸ‡ΈπŸ‡°Slovakia kaszarobert

    Yes, since we are doing this to the main section's classes and styles, it would be awesome if the same thing would work to the section regions as well (for example, in 2 column layout there are 2 section regions: the 1st and the 2nd columns) if possible. That way the module's behavior would be consistent to both cases.

  • I have change the implementation to append styles instead of overwriting them.

  • Status changed to Needs review 5 months ago
  • πŸ‡¨πŸ‡ΏCzech Republic milos.kroulik

    All the change requests seem to be addressed here.

Production build 0.71.5 2024