Do not render the TruncateCenter if text null or empty

This commit is contained in:
nicolas.dorier 2023-04-10 11:17:29 +09:00
parent 7546ef7a8e
commit 8302f082a2
No known key found for this signature in database
GPG key ID: 6618763EF09186FE

View file

@ -1,4 +1,6 @@
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.ViewComponents;
using Microsoft.AspNetCore.Mvc.ViewFeatures;
namespace BTCPayServer.Components.TruncateCenter; namespace BTCPayServer.Components.TruncateCenter;
@ -15,6 +17,8 @@ public class TruncateCenter : ViewComponent
{ {
public IViewComponentResult Invoke(string text, string link = null, string classes = null, int padding = 7, bool copy = true) public IViewComponentResult Invoke(string text, string link = null, string classes = null, int padding = 7, bool copy = true)
{ {
if (string.IsNullOrEmpty(text))
return new HtmlContentViewComponentResult(new StringHtmlContent(string.Empty));
var vm = new TruncateCenterViewModel var vm = new TruncateCenterViewModel
{ {
Classes = classes, Classes = classes,