Skip to content

Truncation occurs even when initial height is equal to max height #75

@iankameron

Description

@iankameron

Example of the issue:
If you have text that fits into two lines and you are clamping to 2 lines, truncation/clamping is unnecessary. However, with the current version you'll lose the last letter of the text and it will be replaced by the ellipsis.
So you might expect:

clamp.js is a fun way
to clamp text

But you get

clamp.js is a fun way
to clamp tex...

This issue seems to be caused by line 221, which calls the initial truncate even when the height matches the max height.
if (height <= element.clientHeight) {

Changing this to a simple '<' seems to fix the problem.

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