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

<Text> does not support numberOfLines or ellipsizeMode #270

Open
dmeehan1968 opened this issue Feb 20, 2018 · 1 comment
Open

<Text> does not support numberOfLines or ellipsizeMode #270

dmeehan1968 opened this issue Feb 20, 2018 · 1 comment

Comments

@dmeehan1968
Copy link
Contributor

👋 Hello! Thanks for contributing. Please use the template that matches your intention

I am...

| -------------------------------------------------------------------------------------------------

Reporting a bug or issue

NB: This is more for bookmarking purposes, it took me a while to uncover that Sketchapp does not support overflow/ellipsis, and felt that creating an issue would allow other people a shortcut.

Expected behavior:

React Native supports text truncation using a combination of numberOfLines and ellipsizeMode.

Observed behavior:

These properties have no effect in Sketch, because the Sketch application doesn't support them.

The <Text> component supports a resizeConstraints property with booleans of top, bottom, left, right, fixedWidth and fixedHeight, and although these have an effect on the containing element, they don't prevent the text from overflowing from the element and affecting element position (when combined with style height/width).

In the screenshot, I've highlighted the long text which has been wrapped to a second line. Note also the text properties which show the resizing constraint (height) and the height of 30 specified via the style={{height:30}}.

How to reproduce:

NB: No point in passing numberOfLines={1} or ellipsizeMode={'head'|'tail'|'middle'} as they are not passed to the underlying text component.

<Text style={{height: 30}} resizingConstraint={{fixedHeight: true}}>
  Home and away this is a very long project title
</Text>

Sketch version:
48.2

Please attach screenshots, a zip file of your project, and/or a link to your github project

sketch

@dmeehan1968
Copy link
Contributor Author

Whilst there is no inherent support for numberOfLines or ellipsizeMode, the reason why Sketchapp renders text outside its container appears to be a Sketch rendering bug. If you select and resize the text object manually, the overflow text is immediately clipped to the object bounds.

I've tried using overflow: 'hidden' on both the Text component's style, and on its containing View but neither prevents the text from overflowing.

I've discovered that there is a technique to place Sketch shapes inside Symbols, as the symbol adds an additional clipping facility (shapes cannot exceed the bounds of the symbol) and this might provide a workaround.

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

1 participant