From 0f574f641e82f7b8712e7ec58d4c913fc4b65727 Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Thu, 12 Jan 2017 12:24:39 +0800 Subject: [PATCH] UX: Truncate topic link title/URL on desktop to prevent overflow. --- .../javascripts/discourse/widgets/topic-map.js.es6 | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/discourse/widgets/topic-map.js.es6 b/app/assets/javascripts/discourse/widgets/topic-map.js.es6 index 67f70aefd9b..4cbcfae591f 100644 --- a/app/assets/javascripts/discourse/widgets/topic-map.js.es6 +++ b/app/assets/javascripts/discourse/widgets/topic-map.js.es6 @@ -116,7 +116,14 @@ createWidget('topic-map-link', { }, html(attrs) { - return attrs.title ? replaceEmoji(attrs.title) : attrs.url; + let content = attrs.title || attrs.url; + const truncateLength = 85; + + if (content.length > truncateLength) { + content = `${content.substr(0, truncateLength).trim()}...`; + } + + return attrs.title ? replaceEmoji(content) : content; } });