From b75ca54a70fa1ae1e8adb386deb7089a2757165b Mon Sep 17 00:00:00 2001 From: niko <644506165@qq.com> Date: Tue, 31 Jul 2018 09:48:27 +0800 Subject: [PATCH] fix Ellipsis break in firefox #1882 (#1921) --- src/components/Ellipsis/index.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/components/Ellipsis/index.js b/src/components/Ellipsis/index.js index 01083bda..9dbee4ad 100644 --- a/src/components/Ellipsis/index.js +++ b/src/components/Ellipsis/index.js @@ -137,11 +137,15 @@ export default class Ellipsis extends Component { if (sh <= th) { shadowNode.innerHTML = text.substring(0, mid + 1) + suffix; sh = shadowNode.offsetHeight; - if (sh > th) { + if (sh > th || mid === begin) { return mid; } else { begin = mid; - mid = Math.floor((end - begin) / 2) + begin; + if (end - begin === 1) { + mid = 1 + begin; + } else { + mid = Math.floor((end - begin) / 2) + begin; + } return this.bisection(th, mid, begin, end, text, shadowNode); } } else { -- GitLab