Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fixed the problem of JS omitting calculation error when display … #2656

Merged
merged 1 commit into from
Jan 2, 2025

Conversation

YyumeiZhang
Copy link
Collaborator

…is none

中文模板 / Chinese Template

What kind of change does this PR introduce? (check at least one)

  • Bugfix
  • Feature
  • Code style update
  • Refactor
  • Test Case
  • TypeScript definition update
  • Document improve
  • CI/CD improve
  • Branch sync
  • Other, please describe:

PR description

Fixes #
#2591 问题修复中,为了获取到 width 为 auto 的容器的实际高度,使用了 offsetWidth,但是当 display 为 none 时候,offsetWidth 将为 0,会导致 JS 缩略计算错误。

复现版本 2.72.0。复现代码

import React from 'react';
import { Tabs, TabPane, Typography } from '@douyinfe/semi-ui';
() => (
    <div>
        <Tabs>
            <TabPane tab="文档" itemKey="1">
                <Typography.Text copyable ellipsis>文档</Typography.Text>
            </TabPane>
            <TabPane tab="快速起步" itemKey="2">
                <Typography.Text copyable ellipsis>快速起步</Typography.Text>
            </TabPane>
            <TabPane tab="帮助" itemKey="3">
                <Typography.Text copyable ellipsis>帮助</Typography.Text>
            </TabPane>
        </Tabs>
    </div>
);

上述问题我们通常是建议用户使用 tabs 的 keepDOM={false} 来保证正确性。
#2591 修改之前 ,表现是虽然无法计算出合理的截断,会显示更多行的数据内容。在#2591 修改之后,会出现只显示...的情况。因此在 width 为auto 的情况下,此次的修改为仅当 offsetWidth 非0 时候,才会将 offsetWidth 作为计算缩略的容器的 width 值。

Changelog

🇨🇳 Chinese

  • Fix: 修复在 display 为 none 时,Typography 的JS 省略计算错误问题

🇺🇸 English

  • Fix: Fixed the problem of Typography’s JS omitting calculation error when display is none

Checklist

  • Test or no need
  • Document or no need
  • Changelog or no need

Other

  • Skip Changelog

Additional information

Copy link

codesandbox-ci bot commented Jan 2, 2025

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 4c69ee9:

Sandbox Source
pr-story Configuration

@DaiQiangReal DaiQiangReal merged commit 9486475 into main Jan 2, 2025
7 checks passed
@DaiQiangReal DaiQiangReal deleted the fix/typo-elipsis branch January 2, 2025 03:35
Copy link

cypress bot commented Jan 2, 2025

semi-design    Run #3036

Run Properties:  status check passed Passed #3036  •  git commit 47a2254c94 ℹ️: Merge 4c69ee9dd53ce048de5772dc6c809a4c1f91e29e into f89e9d7cbc8e0c03744b9a6c750e...
Project semi-design
Branch Review fix/typo-elipsis
Run status status check passed Passed #3036
Run duration 07m 47s
Commit git commit 47a2254c94 ℹ️: Merge 4c69ee9dd53ce048de5772dc6c809a4c1f91e29e into f89e9d7cbc8e0c03744b9a6c750e...
Committer YyumeiZhang
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 11
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 277
View all changes introduced in this branch ↗︎

Copy link

cypress bot commented Jan 2, 2025

semi-design    Run #3037

Run Properties:  status check passed Passed #3037  •  git commit 9486475155: Merge pull request #2656 from DouyinFE/fix/typo-elipsis
Project semi-design
Branch Review main
Run status status check passed Passed #3037
Run duration 08m 01s
Commit git commit 9486475155: Merge pull request #2656 from DouyinFE/fix/typo-elipsis
Committer 代强
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 11
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 277
View all changes introduced in this branch ↗︎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants