-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
Allow for Text components to support a forced minimum number of lines (numberOfLines) #21407
Comments
I personally think that in the example, cell height should be fixed, and contained elements should layout according to available space... |
Cell heights cannot be fixed, due to accessibility concerns. Users who have font scaling set to a high value will have text clipping issues. The height must be dynamic. Below is an example of what happens when font scaling is set in a device's accessibility settings when using static heights: |
@B3rry By fixed I mean that cell height should be set on View, not that this value should be a constant hardcoded in code... Of course you can calculate this value depending on various system conditions. Truth is that yoga currently can't handle text at all and proposed |
Are you saying a calculated height should be applied directly to the <View style={{height: SomeCalculatedHeight}}> Yes, this is an option, but at that point you're still not allowing for standard Flex principles to create a consistently sized text component in a dynamic layout. Is there any reason why consistent, inferred heights should only be available through calculation?
Unsure what you mean.
This is already a factor of
There's probably some considerations around how to take around how you get to some of these values, especially given font scaling and line-height inconsistencies between render in iOS and android. I'm unsure of the full scope of these.
You could use the This process seems rather complex to produce a consistently sized, responsive component. This is a very common UX pattern in iOS and Android, and I don't think relying on each developer to implement their own solution is best, in this case. |
Thanks for starting this discussion. I don't think it makes sense to add |
For Discussion
As of
0.57.0
, the Text component'snumberOfLines
prop is used to define the maximum number of lines of a string that will be rendered before truncation occurs. This is a bit of a misnomer, as one may anticipate that this prop wShould this prop be renamed to something such as
maxNumberOfLines
? Would the maintainers consider the possibility of adding an additional prop, such asminNumberOfLines
, which would force the Text component to occupy the minimum space necessary to render the defined amount of lines?Motivation
Both Android and iOS's interface guidelines specify that when producing a tappable list of items (such as a list of messages) these items should be of even height.
In order to maintain accessible support for font scaling, a cell's height should be inferred from the height of the content, however, it is currently impossible to achieve a consistent inferred height from
Text
's available props.Current Behavior
Anticipated Behavior
The text was updated successfully, but these errors were encountered: