ソースを参照

fix: Fixed the problem of JS omitting calculation error when display is none

zhangyumei.0319 9 ヶ月 前
コミット
4c69ee9dd5
1 ファイル変更1 行追加1 行削除
  1. 1 1
      packages/semi-ui/typography/util.tsx

+ 1 - 1
packages/semi-ui/typography/util.tsx

@@ -66,7 +66,7 @@ const getRenderText = (
     ellipsisContainer.style.left = '0';
     ellipsisContainer.style.left = '0';
     // 当 window.getComputedStyle 得到的 width 值为 auto 时,通过 getBoundingClientRect 得到准确宽度
     // 当 window.getComputedStyle 得到的 width 值为 auto 时,通过 getBoundingClientRect 得到准确宽度
     // When the width value obtained by window.getComputedStyle is auto, get the exact width through 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.width = `${originEle.offsetWidth}px`;
     } 
     } 
     ellipsisContainer.style.height = 'auto';
     ellipsisContainer.style.height = 'auto';