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

BasicTextField doesn't render blank lines correctly #1781

Closed
haikalpribadi opened this issue Feb 2, 2022 · 8 comments
Closed

BasicTextField doesn't render blank lines correctly #1781

haikalpribadi opened this issue Feb 2, 2022 · 8 comments
Assignees
Labels
bug Something isn't working desktop text
Milestone

Comments

@haikalpribadi
Copy link

haikalpribadi commented Feb 2, 2022

If you create a multiline BasicTextField (singleLine = false), and enter a "blank line" (an empty line without any character, or a line with just whitespace), BasicTextField will nor render the text correctly.

For example, let's take this text (you can put a space in the empty line if you want):

abcd

hijk

And compare it against this text:

abcd
x
hijk

First of all, you will see that the empty line will not have the same height as the others -- it will be shorter. See example below.

See screenshot below. The pink border represents the BasicTextField.

BasicTextField bug

Second, in the scenario above, if you enter any number of white space (e.g. 3 spaces), when you move your cursor to the end of the next/previous line that is also longer (e.g. 6 characters), then using the keyboard you move the cursor up/down ONTO that line with the whitespaces, the cursor on the line with only whitespaces will not be shown correctly. The height will be wrong (I suspect because of the first issue above), but also the position is wrong as it always start at position 0, even though it has 3 characters. It should be placed at the end of the 3 whitespace, when moving from another line at a longer position, e.g. 6 chars.

@haikalpribadi
Copy link
Author

By the way, this is turning into a critical and blocking bug for us now :( . The problem is even worse when you enter 2 or more "blank lines" -- they don't get rendered at all. It's really breaking our UI to the point of being dysfunctional. Any chance we can get this patched anytime soon? We really don't want to have implement our own BasicTextField, and we can't use TextField() from Material package as it provides no access to TextLayoutResult (which we need). Thank you!

@igordmn
Copy link
Collaborator

igordmn commented Feb 4, 2022

Thanks for reporting!

Video:

Screen.Recording.2022-02-04.at.11.34.35.mov

Let's move cursor placing to a separate issue

@igordmn igordmn self-assigned this Feb 4, 2022
@igordmn igordmn added bug Something isn't working desktop text labels Feb 4, 2022
@haikalpribadi
Copy link
Author

haikalpribadi commented Feb 4, 2022

Thanks, @igordmn ! do you have an idea on when you think a patch / minor release can be published for the fix?

@igordmn
Copy link
Collaborator

igordmn commented Feb 4, 2022

I will try to investigate this next week, then it depends on complexity. As this issue is partially "fixed" (the first empty line is with the right height), I think there won't be huge obstacles to fix it.

@igordmn igordmn added this to the 1.1 milestone Feb 4, 2022
@haikalpribadi
Copy link
Author

I don't think the first blank line has the right height, btw. See my screenshot above. The line gaps are missing. However, it's true that the second (or more) blank lines are worse.

@milan1201
Copy link

TextField() has the same Issue. Here you can work around it with increasing the lineHeight attribute until blank lines occupy the same amount of space as non-blank ones. The ploblem is that it is different on different screen resolutions.
Maybe you can try the same thing with the style attribute of BasicText() until there is a better solution.

igordmn added a commit to JetBrains/compose-multiplatform-core that referenced this issue Feb 9, 2022
SkiaParagraph doesn't use span style to determine the height of the empty/blank line. It uses main style of the paragraph, which we haven't set.

Fixes JetBrains/compose-multiplatform#1781
@akurasov
Copy link
Contributor

Fixed in 1.1.0-alpha04

igordmn added a commit to JetBrains/compose-multiplatform-core that referenced this issue Feb 18, 2022
SkiaParagraph doesn't use span style to determine the height of the empty/blank line. It uses main style of the paragraph, which we haven't set.

Fixes JetBrains/compose-multiplatform#1781

Change-Id: Ic628a489b7a39f832b172a0d3d5220a4d40778d6
copybara-service bot pushed a commit to androidx/androidx that referenced this issue Mar 1, 2022
SkiaParagraph doesn't use span style to determine the height of the empty/blank line. It uses main style of the paragraph, which we haven't set.

Fixes JetBrains/compose-multiplatform#1781

Change-Id: Ic628a489b7a39f832b172a0d3d5220a4d40778d6
Test: ./gradlew jvmTest desktopTest -Pandroidx.compose.multiplatformEnabled=true
igordmn added a commit to JetBrains/compose-multiplatform-core that referenced this issue Mar 28, 2022
SkiaParagraph doesn't use span style to determine the height of the empty/blank line. It uses main style of the paragraph, which we haven't set.

Fixes JetBrains/compose-multiplatform#1781

# Conflicts:
#	compose/ui/ui-text/src/skikoMain/kotlin/androidx/compose/ui/text/platform/SkiaParagraph.skiko.kt
igordmn added a commit to JetBrains/compose-multiplatform-core that referenced this issue Mar 30, 2022
SkiaParagraph doesn't use span style to determine the height of the empty/blank line. It uses main style of the paragraph, which we haven't set.

Fixes JetBrains/compose-multiplatform#1781

# Conflicts:
#	compose/ui/ui-text/src/skikoMain/kotlin/androidx/compose/ui/text/platform/SkiaParagraph.skiko.kt
igordmn added a commit to JetBrains/compose-multiplatform-core that referenced this issue Apr 4, 2022
SkiaParagraph doesn't use span style to determine the height of the empty/blank line. It uses main style of the paragraph, which we haven't set.

Fixes JetBrains/compose-multiplatform#1781

# Conflicts:
#	compose/ui/ui-text/src/skikoMain/kotlin/androidx/compose/ui/text/platform/SkiaParagraph.skiko.kt
@okushnikov
Copy link
Collaborator

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.

@JetBrains JetBrains locked and limited conversation to collaborators Dec 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working desktop text
Projects
None yet
Development

No branches or pull requests

5 participants