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

Property to refresh/recalculate targetWidth #49

Closed
gamtiq opened this issue Jul 7, 2017 · 3 comments
Closed

Property to refresh/recalculate targetWidth #49

gamtiq opened this issue Jul 7, 2017 · 3 comments

Comments

@gamtiq
Copy link

gamtiq commented Jul 7, 2017

In some cases it is necessary to re-render a truncate component although its existent props (children, ellipsis and lines) are not modified. For example, when size of a parent DOM-element (component) is changed without window resizing.
Now I use the following workaround to re-render the truncate component when necessary: this.truncateRef.onResize();
But it would be useful to have special property which will trigger recalculation of targetWidth.

@pablosichert
Copy link
Owner

Your solution looks good enough to me, I don't think it justifies another property.

If you have strong feelings about this and want to implement that feature I'd accept a PR.

@bongione
Copy link
Contributor

bongione commented Dec 7, 2017

I didn't see this issue until after I had created such a property.
The rationale for having a separate property instead of using the ref is that I can keep all the DOM manipulation within the component, and as a client use it declaratively.

I called the property width, and it simply forces a recalculate size after update if the width property changed. I will create a PR for it.

@pablosichert
Copy link
Owner

You can now control the target size by changing the width property. It's out on npm with 2.4.0.

Thank you for your contribution!

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

3 participants