-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
The cursor is invisible in compose web #3120
Comments
It's been like that for a while, I have been waiting for this for quite some time. Hopefully it gets fixed soon. |
Thanks for the report! |
Also change the mouse pointer arrow to a cursor |
Any workarounds for now? |
it does not allow me to copy or paste content. do any one know reason and fix ? |
For now Compose for Web with Canvas is experimental target. And we have higher priority Issues on other platforms for now. |
thanks so much. can I have a start point so I can work on it ? if possible. @dima-avdeev-jb |
Yes, we have a doc how to prepare dev environment here: |
Just hit this issue myself, so I did some digging into how it happens. The high-level problem is that the Looking into where that This is where the problem originates. Whenever we get the
I'm not sure why it has these values, the underlying implementation goes into In contrast, if we were to read these three values like we do in the special case for empty strings, we'd get good data here:
So it seems we could either:
|
For single-line text editing, option (1) from above seems to work fine, with code as simple as this (though it does not work nicely with multi-line text): text/src/skikoMain/kotlin/androidx/compose/ui/text/SkiaParagraph.skiko.kt
--- a/compose/ui/ui-text/src/skikoMain/kotlin/androidx/compose/ui/text/SkiaParagraph.skiko.kt (revision dd86b0b699a1a7d2e7e24fa08af86d4cce4dcff5)
+++ b/compose/ui/ui-text/src/skikoMain/kotlin/androidx/compose/ui/text/SkiaParagraph.skiko.kt (date 1697991557668)
@@ -263,7 +263,25 @@
)
} else {
@Suppress("UNCHECKED_CAST", "USELESS_CAST")
- paragraph.lineMetrics as Array<LineMetrics>
+ val paragraphMetrics = paragraph.lineMetrics as Array<LineMetrics>
+ val original = paragraphMetrics[paragraphMetrics.lastIndex]
+ val metrics = layouter.defaultFont.metrics
+ paragraphMetrics[paragraphMetrics.lastIndex] = LineMetrics(
+ startIndex = original.startIndex,
+ endIndex = original.endIndex,
+ endExcludingWhitespaces = original.endExcludingWhitespaces,
+ endIncludingNewline = original.endIncludingNewline,
+ isHardBreak = original.isHardBreak,
+ ascent = -metrics.ascent.toDouble(),
+ descent = metrics.descent.toDouble(),
+ unscaledAscent = original.unscaledAscent,
+ height = original.height,
+ width = original.width,
+ left = original.left,
+ baseline = paragraph.alphabeticBaseline.toDouble(),
+ lineNumber = original.lineNumber,
+ )
+ paragraphMetrics
}
private fun getBoxForwardByOffset(offset: Int): TextBox? { Screen.Recording.2023-10-22.at.18.22.38.mov |
@zsmb13 Thanks! Can you please open a Pull Request to branch |
@zsmb13 thank you a lot for your investigation! It's super helpful. Since SkiaParagraph.skiko.kt is a common code for desktop/ios/web we expect it to work everywhere the same way. So I think we'll have to |
Yes, the path definitely breaks multi-line on wasm/web as well, that's why I just added this here and didn't create a PR. I have no idea what I'm doing here, I just kept digging and looked for values that are more sensible 😀 |
Was addressed in JetBrains/skiko#846 |
Also hitting this issue. |
Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks. |
For compose web the cursor is invisible in the TextField.
It's visible only when the TextField is empty but as soon as we type some text the cursor disappears.
Screen.Recording.2023-05-02.at.4.00.16.PM.mov
The text was updated successfully, but these errors were encountered: