Hide the Drafts warning in the sidebar when no draft's send has failed (#247)

The mark carried `hidden` on the Font Awesome <i>, whose .fa-solid rule
sets display and lands after Tailwind's utilities, so it showed at every
count, on every install, with no draft marked. `hidden` now sits on a
wrapper span with no other display utility (an `inline-flex` beside it
won as well). The test checks for both.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Paul LütznerandClaude Opus 5.5 authored and GitHub committed 2026-10-20 12:51:49 +02:00
1 parent ea70139077
commit 880f338d53
2 files changed
+25 -8

No files matched your search

+16 -6
View File
@@ -12,6 +12,12 @@ The sidebar's is rendered at every count and hidden at zero, the idiom every
patched marker follows (see _new_dot.html.twig): ui--sidebar finds it by
`data-count-key` after a counts refresh, and an element never rendered cannot
be found.
`hidden` goes on a wrapper, never on the <i>: Font Awesome's .fa-solid sets
`display` and lands after Tailwind's utilities, so a `hidden` on the icon is
overridden and the mark shows at zero — which is how it first shipped, on every
install, with no draft marked at all. _thread_row.html.twig wraps its icons for
the same reason.
#}
{% macro row(failure) %}
{% set reason = ('thread_row.send_failed.' ~ failure.value)|trans %}
@@ -23,10 +29,14 @@ be found.
{% endmacro %}
{% macro sidebar(count) %}
<i class="fa-solid fa-triangle-exclamation text-red-600 dark:text-red-400 text-xs{{ count > 0 ? '' : ' hidden' }}"
role="img"
data-unsent-mark
data-count-key="unsent:role:drafts"
title="{{ 'sidebar.badge.unsent'|trans }}"
aria-label="{{ 'sidebar.badge.unsent'|trans }}"></i>
{# No display utility beside `hidden`: one of those would be a second
`display` competing with it, and it lost to `inline-flex` here once. #}
<span class="text-xs{{ count > 0 ? '' : ' hidden' }}"
role="img"
data-unsent-mark
data-count-key="unsent:role:drafts"
title="{{ 'sidebar.badge.unsent'|trans }}"
aria-label="{{ 'sidebar.badge.unsent'|trans }}">
<i class="fa-solid fa-triangle-exclamation text-red-600 dark:text-red-400" aria-hidden="true"></i>
</span>
{% endmacro %}
@@ -58,7 +58,7 @@ final class UnsentDraftWarningTest extends WebTestCase
$mark = $crawler->filter('[data-unsent-mark]')->first();
self::assertStringNotContainsString('hidden', (string) $mark->attr('class'), 'and Drafts in the sidebar shows it');
self::assertStringContainsString('fa-triangle-exclamation', (string) $mark->attr('class'), 'as the same triangle');
self::assertCount(1, $mark->filter('i.fa-triangle-exclamation'), 'as the same triangle');
self::assertSame(1, $this->counts($client)['unsent:role:drafts'], 'and the live counts agree');
}
@@ -72,7 +72,14 @@ final class UnsentDraftWarningTest extends WebTestCase
self::assertResponseIsSuccessful();
self::assertCount(0, $crawler->filter('[data-unsent-draft]'));
self::assertStringContainsString('hidden', (string) $crawler->filter('[data-unsent-mark]')->first()->attr('class'), 'rendered, but hidden at zero');
$mark = $crawler->filter('[data-unsent-mark]')->first();
self::assertStringContainsString('hidden', (string) $mark->attr('class'), 'rendered, but hidden at zero');
self::assertStringNotContainsString('fa-', (string) $mark->attr('class'),
'and hidden by an element Font Awesome does not style: its .fa-solid sets display after '
. 'Tailwind, so `hidden` on the icon itself does not hide it');
self::assertDoesNotMatchRegularExpression('/(^|\s)(inline-flex|inline-block|flex|block|inline|grid)(\s|$)/', (string) $mark->attr('class'),
'and with no other display utility competing with `hidden`');
self::assertSame(0, $this->counts($client)['unsent:role:drafts']);
}