Skip to content

Width calculation is using the window width and not the parent element's width #32

@drew-wallace

Description

@drew-wallace

If I put a Truncate component in a div with padding, the generated elements are too long. Once I removed the padding, the generated elements fit to the appropriate number of lines.

It seems that you are calculating the appropriate width based on the width of the window and not the width of the Truncate component's parent. Consequently, if you calculate the width of the parent div instead of the window, you can rely on normal text wrapping instead of the current span + br pattern.

Example: go to your demo page, inside ReadMore.js, add this to div surrounding the Truncate component: style={{padding: 15}}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions