[frontend/components] Use IsNullOrWhiteSpace to check if attachment has alt text

This commit is contained in:
pancakes 2024-12-15 12:14:44 +10:00 committed by Laura Hausmann
parent c131efc7c8
commit ce16fca697
No known key found for this signature in database
GPG key ID: D044E84C5BE01605

View file

@ -35,7 +35,7 @@
</span>
}
@if (Attachment.AltText != null)
@if (!string.IsNullOrWhiteSpace(Attachment.AltText))
{
<button @onclick="DisplayAlt" @onclick:stopPropagation="true" class="alt-btn" title="@Attachment.AltText">
<Icon Name="Icons.ClosedCaptioning"/>
@ -75,6 +75,6 @@
private async Task DisplayAlt()
{
await Js.InvokeVoidAsync("alert", Attachment.AltText ?? Loc["No alt text"]);
await Js.InvokeVoidAsync("alert", string.IsNullOrWhiteSpace(Attachment.AltText) ? Loc["No alt text"] : Attachment.AltText);
}
}