From 4c69ee9dd53ce048de5772dc6c809a4c1f91e29e Mon Sep 17 00:00:00 2001 From: "zhangyumei.0319" Date: Mon, 30 Dec 2024 19:18:45 +0800 Subject: [PATCH] fix: Fixed the problem of JS omitting calculation error when display is none --- packages/semi-ui/typography/util.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/semi-ui/typography/util.tsx b/packages/semi-ui/typography/util.tsx index be45ab3be3..9027f07087 100644 --- a/packages/semi-ui/typography/util.tsx +++ b/packages/semi-ui/typography/util.tsx @@ -66,7 +66,7 @@ const getRenderText = ( ellipsisContainer.style.left = '0'; // 当 window.getComputedStyle 得到的 width 值为 auto 时,通过 getBoundingClientRect 得到准确宽度 // When the width value obtained by window.getComputedStyle is auto, get the exact width through getBoundingClientRect - if (originStyle.getPropertyValue('width') === 'auto') { + if (originStyle.getPropertyValue('width') === 'auto' && originEle.offsetWidth) { ellipsisContainer.style.width = `${originEle.offsetWidth}px`; } ellipsisContainer.style.height = 'auto';