From fabec34557c5ebb31b191776b850fb7af944f290 Mon Sep 17 00:00:00 2001 From: Jas Singh Date: Sat, 9 Nov 2024 17:18:29 -0800 Subject: [PATCH] Added ellipses to truncated media label if the media label is larger than the truncation size. (#471) --- modules/bar/media/helpers.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/modules/bar/media/helpers.ts b/modules/bar/media/helpers.ts index b6362f3..04ffcf6 100644 --- a/modules/bar/media/helpers.ts +++ b/modules/bar/media/helpers.ts @@ -73,8 +73,13 @@ export const generateMediaLabel = ( }, ); - const mediaLabel = - truncation_size.value > 0 ? truncatedLabel.substring(0, truncation_size.value) : truncatedLabel; + const maxLabelSize = truncation_size.value; + + let mediaLabel = truncatedLabel; + + if (maxLabelSize > 0 && truncatedLabel.length > maxLabelSize) { + mediaLabel = `${truncatedLabel.substring(0, maxLabelSize)}...`; + } return mediaLabel.length ? mediaLabel : 'Media'; } else {