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

fix: ellipses are not displayed when the text contains line breaks #1835

Merged
merged 3 commits into from
Nov 14, 2024

Conversation

wang1212
Copy link
Member

@wang1212 wang1212 commented Nov 13, 2024

🤔 This is a ...

  • New feature
  • Bug fix
  • Site / Document optimization
  • TypeScript definition update
  • Refactoring
  • Performance improvement
  • Code style optimization
  • Test Case
  • Branch merge
  • Other (about what?)

🔗 Related issue link

When we configure wordWrap wordWrapWidth textOverflow maxLines to achieve automatic text wrapping, if the text content happens to be multiple lines of text separated by line breaks, and the number of lines is greater than the maxLines configuration, the ellipsis will not be displayed, which is not as expected.

const text = new Text({
  style: {
    x: 0,
    y: 0,
    fill: '#000000',
    maxLines: 2,
    text: 'abc\ndef\nghi', // number of lines is greater than the `maxLines`
    textOverflow: 'ellipsis',
    wordWrap: true,
    wordWrapWidth: 84,
  },
});

💡 Background and solution

In any case, when the maxLines threshold is reached, the logic of appending ellipsis should be executed.

📝 Changelog

Language Changelog
🇺🇸 English fix: ellipses are not displayed when the text contains line breaks
🇨🇳 Chinese fix: 当文本中包含换行符时省略号不显示

☑️ Self Check before Merge

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • TypeScript definition is updated/provided or not needed
  • Changelog is provided or not needed

@wang1212 wang1212 merged commit ad11268 into release Nov 14, 2024
3 checks passed
@wang1212 wang1212 deleted the fix-text branch November 14, 2024 07:59
wang1212 added a commit that referenced this pull request Nov 14, 2024
* fix: ellipses are not displayed when the text contains line breaks (#1835)

* fix: ellipses are not displayed when the text contains line breaks

* fix: edge cases for adding ellipsis to text wrapping

* fix: code modifications missed in the previous version

* Version Packages (#1836)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
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

Successfully merging this pull request may close these issues.

2 participants