Преглед изворни кода

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';
     // 当 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';