diff --git a/client/src/components/Common/TextSummary.vue b/client/src/components/Common/TextSummary.vue index 19b7f40e98c7..6ef4b607402d 100644 --- a/client/src/components/Common/TextSummary.vue +++ b/client/src/components/Common/TextSummary.vue @@ -11,7 +11,8 @@ interface Props { maxLength?: number; /** The text to summarize */ description: string; - /** If `true`, doesn't let unexpanded text go beyond height of one line */ + /** If `true`, doesn't let unexpanded text go beyond height of one line + * and ignores `maxLength` */ oneLineSummary?: boolean; /** If `true`, doesn't show expand/collapse buttons */ noExpand?: boolean; @@ -25,8 +26,17 @@ const props = withDefaults(defineProps(), { }); const showDetails = ref(false); +const refOneLineSummary = ref(null); -const textTooLong = computed(() => props.description.length > props.maxLength); +const textTooLong = computed(() => { + if (!props.oneLineSummary) { + return props.description.length > props.maxLength; + } else if (refOneLineSummary.value) { + return refOneLineSummary.value.scrollWidth > refOneLineSummary.value.clientWidth; + } else { + return false; + } +}); const text = computed(() => textTooLong.value && !showDetails.value ? props.description.slice(0, Math.round(props.maxLength - props.maxLength / 2)) + "..." @@ -35,8 +45,12 @@ const text = computed(() =>