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: TextBoxComponent rendering for new line #2413
Conversation
This commit changes how we calculate and fill lines when checking for bounds
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lgtm, could you add a test?
Great. I will add. So, the reason I put it as draft. |
Should I be using the golden tests? if so, what should be my approach in generating images for it? |
If you don't really want to, I think you can skip using goldens for this change. I think it's enough to just verify that the height is correct, and possibly verify that the list has the correct words on each line. To do the last part you'd have to move out the list from the method and expose it with |
I can use the goldens, that's not a problem just that (I can refer the already present test), is it just writing the app and screenshotting it or is there any other way for it?
This I can do.
The I am ready with anything what you suggest. |
Setting it as public but with the visibleForTesting tag is virtually the same as having it as private, so it should be fine. :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job!
For future: the |
Wow. I literally missed it. Thank you. |
Initially the calculation of lines and updating accordingly ignores the case for a new line escape characters.
This PR changes how we calculate and update lines when checking for bounds.
Description
Before:
When a text that contains
\n
character is given to the TextBox for exampleHello \n World
. It doesn't consider the new line and just appends the\n
to the same line. This increases the lineHeight for that particular word (and won't be updated in this case). But, instead when there is a text\nHello World
, then the initial lineHeight itself is twice than what it actually is.So, the main problem here is that we are not considering (ignoring) the
\n
characters.This can be solved by checking for any new lines in the split word (From
split(' ')
) by usingsplit('\n')
and adding the lines appropriately into the_lines
.After:
Now, whenever a
\n
is encountered, we respect both the new line and the spacing right after the\n
character. This eliminates the improper rendering of the text. Also,lineHeight
will always be same as expected and not more.Screenshots
Input1:
Hello \n something great World
Output1:
Input2:
\nHello\nsomething great World'
Output2:
Checklist
docs
and added dartdoc comments with///
.examples
ordocs
.Migration instructions
Related Issues
Closes #1622