CezaryDanielNowak / React-dotdotdot

Multiline text ellipsis for react. Demo:
https://nowak.click/react-dotdotdot/
MIT License
401 stars 54 forks source link

Ellipsis does not work for long text #59

Open aron-hivebrite opened 3 years ago

aron-hivebrite commented 3 years ago

Hello Mr CezaryDanielNowak,

I have tried to use your Dotdotdot component like this

<Dotdotdot clamp={2}>
  hello everyonFRRRRRRRRRRRRRRRReveryonFRRRRRRRRRRRRRRRReveryonFRRRRRRRRRRRRRRRReveryonFRRRRRRRRRRRRRRRReveryonFRRRRRRRRRRRRRRRReveryonFRRRRRRRRRRRRRRRReveryonFRRRRRRRRRRRRRRRR
</Dotdotdot>

And I got:

Capture d’écran 2021-02-17 à 21 58 23

So, I did the following changes:

const ClampedText = styled(Box)`
  overflow: hidden;
  text-overflow: ellipsis;
  -webkit-box-orient: vertical;
  display: inline-block;
  white-space: nowrap;
  -webkit-line-clamp: ${(props) => props.clamp ?? 1};
`;

And I used it like that:

<ClampedText clamp={2}>
  hello everyonFRRRRRRRRRRRRRRRReveryonFRRRRRRRRRRRRRRRReveryonFRRRRRRRRRRRRRRRReveryonFRRRRRRRRRRRRRRRReveryonFRRRRRRRRRRRRRRRReveryonFRRRRRRRRRRRRRRRReveryonFRRRRRRRRRRRRRRRR
</ClampedText>

And it worked for me:

Capture d’écran 2021-02-17 à 22 00 21

I only have changed the value of display and have added white-space.

Could you confirm if it is a bug in the component please?

Thx in advance.