From df1f755150c4d59fbc8967806ade6d627242ca9a Mon Sep 17 00:00:00 2001 From: Martin Raifer Date: Tue, 27 Sep 2022 14:00:28 +0200 Subject: [PATCH] don't show empty tooltips in backgrounds list --- modules/renderer/background_source.js | 7 +++++++ modules/ui/sections/background_list.js | 6 +++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/modules/renderer/background_source.js b/modules/renderer/background_source.js index e543f5004..9d92416e6 100644 --- a/modules/renderer/background_source.js +++ b/modules/renderer/background_source.js @@ -79,6 +79,13 @@ export function rendererBackgroundSource(data) { }; + source.hasDescription = function() { + var id_safe = source.id.replace(/\./g, ''); + var descriptionText = localizer.tInfo('imagery.' + id_safe + '.description', { default: escape(_description) }).text; + return descriptionText !== ''; + }; + + source.description = function() { var id_safe = source.id.replace(/\./g, ''); return t.append('imagery.' + id_safe + '.description', { default: escape(_description) }); diff --git a/modules/ui/sections/background_list.js b/modules/ui/sections/background_list.js index 39c6c7a71..f889b5e1b 100644 --- a/modules/ui/sections/background_list.js +++ b/modules/ui/sections/background_list.js @@ -142,7 +142,7 @@ export function uiSectionBackgroundList(context) { var item = d3_select(this).select('label'); var span = item.select('span'); var placement = (i < nodes.length / 2) ? 'bottom' : 'top'; - var description = d.description(); + var hasDescription = d.hasDescription(); var isOverflowing = (span.property('clientWidth') !== span.property('scrollWidth')); item.call(uiTooltip().destroyAny); @@ -153,10 +153,10 @@ export function uiSectionBackgroundList(context) { .title(() => t.append('background.switch')) .keys([uiCmd('⌘' + t('background.key'))]) ); - } else if (description || isOverflowing) { + } else if (hasDescription || isOverflowing) { item.call(uiTooltip() .placement(placement) - .title(() => description || d.label()) + .title(() => hasDescription ? d.description() : d.label()) ); } });