Handled nullable content and improved null checks in MudCopyClipboardButton.

This commit is contained in:
Thorsten Sommer 2025-08-09 21:42:53 +02:00
parent e4cd2a75a1
commit eca0d33da3
Signed by: tsommer
GPG Key ID: 371BBA77A02C0108

View File

@ -48,10 +48,10 @@ public partial class MudCopyClipboardButton : ComponentBase
private async Task HandleCopyClick()
{
if (this.Type == ContentType.NONE)
if (this.Type is ContentType.NONE)
await this.CopyToClipboard(this.StringContent);
else
await this.CopyToClipboard(this.Content!);
await this.CopyToClipboard(this.Content);
}
/// <summary>
@ -65,8 +65,11 @@ public partial class MudCopyClipboardButton : ComponentBase
/// <summary>
/// Copy this block's content to the clipboard.
/// </summary>
private async Task CopyToClipboard(IContent contentToCopy)
private async Task CopyToClipboard(IContent? contentToCopy)
{
if (contentToCopy is null)
return;
switch (this.Type)
{
case ContentType.TEXT: