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

[BUG] <Typography>Text children 为模版字符串时的省略异常 #2167

Closed
1 task done
YyumeiZhang opened this issue Apr 12, 2024 · 1 comment · Fixed by #2169
Closed
1 task done

[BUG] <Typography>Text children 为模版字符串时的省略异常 #2167

YyumeiZhang opened this issue Apr 12, 2024 · 1 comment · Fixed by #2169

Comments

@YyumeiZhang
Copy link
Collaborator

Is there an existing issue for this?

  • I have searched the existing issues

Which Component

Typography

Semi Version

2.55.5

Current Behavior

image

Expected Behavior

image

Steps To Reproduce

No response

ReproducibleCode

function Demo() {
  const { Text } = Typography;
  const code = 'code'; 

  return <Text 
            style={{  marginTop: 6, color: 'var(--semi-color-text-2)' }}
            ellipsis={{ showTooltip: { opts: { style: { wordBreak: 'break-word' } } } }}
            copyable={{ content: code }}>
            Key: {code}
        </Text>
}

Environment

- OS:
- browser:

Anything else?

No response

@YyumeiZhang
Copy link
Collaborator Author

YyumeiZhang commented Apr 12, 2024

问题原因:
文档中强调了应该传入 string。
当以上述方式传入 Text 的children, 看上去是字符串,实际上在 React 中数组
image

由于此前代码中https://github.com/DouyinFE/semi-design/blob/v2.55.5/packages/semi-ui/typography/base.tsx#L375 对children 做了强制转换,因此引入了 逗号,省略前后的文本不同,所以认为出现了截断

用户可以通过将模版字符串单独用变量进行定义,然后作为 children,但是考虑到用户可能考虑不到模版字符串非 string 类型,应该对模版字符串的方式做兼容

@YyumeiZhang YyumeiZhang changed the title [BUG] <Typography>Text children 为数组时的省略异常 [BUG] <Typography>Text children 为模版字符串时的省略异常 Apr 12, 2024
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 a pull request may close this issue.

1 participant