react-show-more icon indicating copy to clipboard operation
react-show-more copied to clipboard

On page load, component renders over many lines

Open philest opened this issue 7 years ago • 6 comments

Observed Behavior 1-2 seconds after page-load: screenshot 2017-10-23 12 26 18

Expected Behavior: screenshot 2017-10-23 12 27 02

philest avatar Oct 23 '17 18:10 philest

@PabloSichert

philest avatar Oct 23 '17 19:10 philest

Update: In other cases, it hangs in the broken state permanently, until the window is resized. This is a pretty serious bug and can make the component unusuable:

screenshot 2017-10-23 14 05 20

philest avatar Oct 23 '17 20:10 philest

I'm getting the same issue, and some lines are being hidden completely.

screen shot 2017-12-14 at 4 26 20 pm

cxreiff avatar Dec 15 '17 00:12 cxreiff

@philest @jaxuru @PabloSichert The root of the problem is that it randomly adds br tags in the text. Just wrap the code in a div tag with a class name of your choice and then do this in your CSS file:

.your-className br { display: none; }

.your-className span { margin-right: 4px; }

Jachaplin avatar Nov 04 '18 21:11 Jachaplin

I had a similar issue and tracked it down to using letter-spacing in our CSS, which is a known limitation of react-truncate: https://github.com/One-com/react-truncate/issues/59

timrossinfo avatar Nov 21 '18 23:11 timrossinfo

I've fixed it by storing a ref to the Truncate component within the ShowMore component and then calling the truncate function manually after the Truncate is loaded

componentDidUpdate() { this.truncateRef.current.calcTargetWidth(); }

It might cause some performance loss though, but it seems insignificant for now.

Slitthe avatar May 29 '19 07:05 Slitthe