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 renderRule is not accepting textBreakStrategy prop #52

Closed
abelyeupear opened this issue Feb 12, 2020 · 7 comments
Closed

Text renderRule is not accepting textBreakStrategy prop #52

abelyeupear opened this issue Feb 12, 2020 · 7 comments

Comments

@abelyeupear
Copy link

Since Android 10, textBreakStrategy="simple" is necessary for the text not to break in a way that can hide the last word of the text. Apparently, only the prop mentioned above solves this issue.

I tried adding this prop to the text renderRule like:

text: (node, children, parent, styles) => {
    return <Text key={node.key} textBreakStrategy="simple">{node.content}</Text>;
  },

But the prop is not being applied appropriately, or, at least, the text is still breaking. I have two questions:

  1. Am I missing something about how this is supposed to work?
  2. Is there a way to make sure this textBreakStrategy="simple" is applied?
@jayshah123
Copy link

Yes, It seems even "numberOfLines" prop is not respected right now.

@abelyeupear
Copy link
Author

So, apparently, the prop does apply to the textgroup rule!
I still don't quite understand how the parser/renderer works, and why it would be textgroup vs. text rule, but it certainly did the trick.
Hope this helps!

@iamacup
Copy link
Owner

iamacup commented Feb 21, 2020

A couple of things here - the horrible textgroup / text hierarchy is explained here: #42 (comment)

Its a pain.... but I don't know another way of doing it.

@jayshah123 as a consequence of having to nest the text elements - this bug: facebook/react-native#22811 is causing the numberOfLines prop to not work

@abelyeupear i am struggling to replicate the underlying issue on an emulator set to API 29 // Android 10 - what specifically is happening? can you provide me a sample / screenshots? :)

@iamacup iamacup added the question Further information is requested label Feb 21, 2020
@iamacup
Copy link
Owner

iamacup commented Feb 28, 2020

Closing because i am not sure what next steps are without some help from @abelyeupear - feel free to reopen

@iamacup iamacup closed this as completed Feb 28, 2020
@abelyeupear
Copy link
Author

Sorry, busy week!
No need to reopen, I think the issue was mainly that it the prop had to go into the textgroup rule. I haven't had time to look into the text/textgroup hierarchy, but if that needed to get fixed at some point, it sounds like a completely different issue.

The steps to reproduce are mainly: Android 10 (emulator or not), <Text> component and enough text to break the line into a new line by one word only. In Android 10, this word won't show up.
The fix is to use textBreakStrategy='simple' in the Text component, in the textgroup rule.

@iamacup
Copy link
Owner

iamacup commented Feb 28, 2020

I will reopen because it seems that the default textgroup rule should maybe have the breackStrat added as you say,

Will do some more testing over the next couple of days and see!

@iamacup iamacup reopened this Feb 28, 2020
@iamacup iamacup added bug Something isn't working enhancement New feature or request and removed question Further information is requested labels Mar 23, 2020
@iamacup iamacup mentioned this issue Mar 31, 2020
@iamacup iamacup added nested-<Text>-related 7.x.x and removed bug Something isn't working labels Jul 3, 2020
@helsonxiao
Copy link

I use this rule as a workaround for numberOfLines.

const rules: RenderRules = {
  ...YourRules,
  textgroup: node => {
    return (
      <Text
        key={node.key}
        numberOfLines={3}
      >
        {node.children?.[0].content}
      </Text>
    );
  },
};

@iamacup iamacup closed this as completed Dec 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants