如何知道material-ui TextField是否被截断

发布于 2025-01-13 12:13:17 字数 334 浏览 3 评论 0原文

我已经为我的 TextField mui 组件指定了自定义样式,如下所示:

'& > * .MuiFilledInput-input': {
  overflow: 'hidden',
  textOverflow: 'ellipsis',
},

这是为了在 TextField 内截断文本时显示省略号。这工作正常,但现在我需要仅在文本被截断时显示工具提示。因此,我需要找出上面的样式是否使用了 TextField 或者文本是否被截断。我不想使用硬编码的长度/宽度方法,而是动态查找它。有什么想法如何去做吗?

I have given a custom styling to my TextField mui component like below:

'& > * .MuiFilledInput-input': {
  overflow: 'hidden',
  textOverflow: 'ellipsis',
},

This is to show the ellipsis when the text is truncated inside TextField. This works fine but now I need to show a tooltip only when the text is truncated. So somehow I need to find out if the TextField used above styling or if the text was truncated. I do not want to use hard-coded length/width approach but instead find it out dynamically. Any ideas how to do it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文