Change record status: 
Project: 
Introduced in branch: 
10.x
Description: 

Currently, if we create a fieldset element with an empty title eg:

  $form['test_empty'] = [
    '#type' => 'fieldset',
    '#title' => '',
    '#description' => '',
  ];

then it will create an empty <legend> tag, ideally, it should not create a title element when the title is empty, So added a condition to the title element

Before

  <legend{{ legend.attributes }}>
    <span{{ legend_span.attributes.addClass(legend_span_classes) }}>{{ legend.title }}</span>
  </legend>

After

  {% if legend.title %}
    <legend{{ legend.attributes }}>
      <span{{ legend_span.attributes.addClass(legend_span_classes) }}>{{ legend.title }}</span>
    </legend>
  {% endif %}
Impacts: 
Themers