Details element not correctly handling the #open attribute.

Created on 24 July 2024, 3 months ago
Updated 25 July 2024, 3 months ago

Problem/Motivation

According to the documentation, passing the attribute `'#open' => FALSE` to the Details element will output the <details> as collapsed by default.

It's not, the Details element just checks if `#open` is specified, without checking the value.

Steps to reproduce

Generate a custom form and add a details element to it :

$form['more_details'] = [
      '#type' => 'details',
      '#title' => t('More details in here'),
      '#open' => FALSE,
    ];

The "More details in here" <details> element will be shown open.

Proposed resolution

Check the value of `#open`, if FALSE, do not make the element open.

Remaining tasks

I need to create a PR and run the tests to make sure it doesn't break anything.

API changes

None, if the documentation is right.

Data model changes

None.

Notes

I've filed this in the `render system` component, since it happens in lib/Drupal/Render/Element/Details.php, but I have no idea what I'm doing.

🐛 Bug report
Status

Closed: cannot reproduce

Version

11.0 🔥

Component
Render 

Last updated 7 days ago

Created by

🇨🇦Canada pierre paul lefebvre

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

Comments & Activities

Production build 0.71.5 2024