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

clamping doesnt respect newlines #36

Open
doug31415 opened this issue Feb 20, 2020 · 1 comment
Open

clamping doesnt respect newlines #36

doug31415 opened this issue Feb 20, 2020 · 1 comment

Comments

@doug31415
Copy link

doug31415 commented Feb 20, 2020

STR:

  • Add text with newlines, eg:
const text = '1\n 1\n  1\n  1\n  1\n  1\n  1\n  1\n  1\n  1\n  1\n  1\n  1\n  1\n  1\n  1\n '
<ClampLines
          className={this.state.cssClasses}
          text={this.text}
        />
  • Note that all the lines are collapsed into one line
  • Then add a CSS of white-space: pre-wrap
  • Note that newlines are preserved but no truncation occurs
@JavierPDev
Copy link

JavierPDev commented Jun 19, 2020

To add some more detail to this, it seems to work properly for me on the initial mount, but when the text prop changes, it doesn't. I was lucky in circumstances that allowed me to realize that tidbit, I hope it helps. Might be something with componentDidUpdate vs. componentDidMount.

For now I'm getting around this issue by passing a new key prop (eg. key={Date.now()} on each render of the parent component (since a key prop change forces remount instead of just a normal update on all react components).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants