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

When text prop is only 2 characters, only truncateText is displayed #69

Open
brianchenault opened this issue Nov 9, 2018 · 2 comments

Comments

@brianchenault
Copy link

brianchenault commented Nov 9, 2018

<TextTruncate line={2} truncateText='...' text={'V3'}></TextTruncate>

simply displays '...'.

If I add another character to make it 'V33', for instance, it displays text. The div container this is in is 320px, so plenty of room there.

@ShinyChang ShinyChang added the bug label Nov 11, 2018
@ShinyChang
Copy link
Owner

Will fix it recently

@Bharat-pdgt
Copy link

@ShinyChang any update on this bug?

Casilio pushed a commit to Casilio/React-Text-Truncate that referenced this issue Feb 21, 2022
This happens if the truncate-component if wrapped by a flex element,
and that flex element only takes minimal required space to fix its
content.

The issue here is that `measureText` methods uses rounding, while
width of the truncate component's ref is calculated without rounding.

Removing rounding and applying good-enough floats comparison
fixes the issue.
ShinyChang pushed a commit that referenced this issue Feb 21, 2022
* Issue #69 | Don't truncate if text fits into an element

This happens if the truncate-component if wrapped by a flex element,
and that flex element only takes minimal required space to fix its
content.

The issue here is that `measureText` methods uses rounding, while
width of the truncate component's ref is calculated without rounding.

Removing rounding and applying good-enough floats comparison
fixes the issue.

* Add css for the example

Co-authored-by: Pavel Savchuk <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants