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
Text noOfLines 1 whitespace with long words #8311
Comments
Hey Haley! Thanks for your contribution. I observed that by default, when using I think it would be wise to start a discussion about this change, because at the same time it makes more sense to use What do you think of this? |
What I meant is that should be a discussion whether |
Thank you for clarifying! I 100% agree and would love to move forward with that discussion. Seems like it would be a good improvement. |
Description
When using the Text component with
noOfLines
of 1, I would expect that the end word would break anywhere. Instead, the whole word wraps which causes empty whitespace.Current behavior:
Expected behavior:
Link to Reproduction
Link
Steps to reproduce
noOfLines
to 1Chakra UI Version
2.5.4
Browser
No response
Operating System
Additional Information
I've tried handling this on my own 2 ways:
-webkit-line-clamp
value to see if the currentnoOfLines
is 1. The issue with this is that line-clamp is computed as none whennoOfLines
is a ResponsiveValue.useCurrentBreakpointValue
hook, which take a ResponsiveValue, maps that to a breakpoint value object ({base: '', sm: '', md: '', ...}
), and then uses theuseBreakpointValue
hook to get the current value.With both of these solutions, I would check if the text is truncated and if
noOfLines === 1
, if so then I would setword-break: "break-all"
.However, I think this is super hacky and causes some undesirable flickering when rendering and resizing the browser. It would be nice if this is handled in the Text component itself.
The text was updated successfully, but these errors were encountered: