-
Notifications
You must be signed in to change notification settings - Fork 81
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
iOS fix keyboard crash #1383
iOS fix keyboard crash #1383
Conversation
} | ||
|
||
val key = specialTypeKey ?: pressKey?.keyCode?.let { Key(it) } ?: Key.Unknown | ||
val codePoint = pressKey?.characters?.firstOrNull()?.code ?: 0 |
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.
Please reuse our internal helper String.codePointAt(index: Int): CodePoint
instead of firstOrNull
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.
I feel hesitant to introduce this change in this PR:
- I'm not owning this piece of code.
- This is out of the scope of the fix.
- So far we have no issues related to it.
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.
Let's add explicit TODO at least
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.
Done
compose/ui/ui/src/uikitMain/kotlin/androidx/compose/ui/input/key/KeyEvent.uikit.kt
Outdated
Show resolved
Hide resolved
…ey/KeyEvent.uikit.kt Co-authored-by: Ivan Matkov <ivan.matkov@jetbrains.com>
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.
Apart from what Ivan wrote about don't see anything unacceptable )
// can be potentially nil on TVOS, this will cause a crash | ||
val uiKey = requireNotNull(key) { | ||
"UIPress with null key is not supported" | ||
val pressKey = key |
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.
Well, if we don't need any additional check then (why btw?) then this variable is redundant and we can just use key
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.
Aha, removed extra variable and avoided shadowing this.key
with local key
.
compose/ui/ui/src/uikitMain/kotlin/androidx/compose/ui/input/key/KeyEvent.uikit.kt
Outdated
Show resolved
Hide resolved
…ey/KeyEvent.uikit.kt Co-authored-by: Ivan Matkov <ivan.matkov@jetbrains.com>
Properly handle UIPress with
key == nil
Fixes a crash JetBrains/compose-multiplatform#4911
Testing
The reported issue doesn't reproduce anymore.
Release Notes
Fixes - iOS