Hi there,

when I have a status message following a warning message, the status message has also the warning class in it.
I think the problem is the attributes variable in the status-messages.html.twig which is not somehow reset for every loop in the for statement.

{% for type, messages in message_list %}
  {%
    set classes = [
      'messages',
      'messages--' ~ type,
    ]
  %}
  <div class="{{ attributes.addClass(classes).class }}" role="contentinfo" aria-label="{{ status_headings[type] }}">
    {% if type == 'error' %}
      <div role="alert">
    {% endif %}
      {% if status_headings[type] %}
        <h2 class="visually-hidden">{{ status_headings[type] }}</h2>
      {% endif %}

any ideas? where are the twig specialists?! :-)

greetings ifux

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tim.plunkett’s picture

Issue tags: +Twig

No idea why this is done in twig. This would be much easier in PHP. I have no idea how to reset attributes in each loop.

damiankloip’s picture

tim.plunkett’s picture

Issue tags: +Needs tests
legolasbo’s picture

I'll write some tests for this issue.

legolasbo’s picture

Status: Active » Needs review
Issue tags: -Needs tests
FileSize
2.19 KB

Attached patch adds tests for this issue, which will obviously fail since there is no patch yet.

Status: Needs review » Needs work

The last submitted patch, 5: wrong_classes_on_status-2345005-5.patch, failed testing.

lauriii’s picture

Assigned: Unassigned » lauriii
lauriii’s picture

Assigned: lauriii » Unassigned
Status: Needs work » Closed (duplicate)