-
Notifications
You must be signed in to change notification settings - Fork 77
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 web key mappings #1249
Fix web key mappings #1249
Conversation
compose/mpp/demo/src/commonMain/kotlin/androidx/compose/mpp/demo/bug/BugReproducers.kt
Outdated
Show resolved
Hide resolved
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 think we need more tests but this is a good start
Also, I can imagine us iving without bug reproducer at all (because indeed we'll have test)
canvasElement.dispatchEvent(createTypedEvent('e')) | ||
canvasElement.dispatchEvent(createTypedEvent('s')) | ||
canvasElement.dispatchEvent(createTypedEvent('t')) | ||
assertEquals(Key.T, lastKeyEvent!!.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.
I might be missing something but how we are sure that this is the last "t"-event, not the first one?
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.
Changed the tests to avoid this potential issue.
val KeyEventMappingsBugReproducer = Screen.Example("KeyEventMappingsBugReproducer (web)") { | ||
val focusRequester = remember { FocusRequester() } | ||
Box(Modifier.size(1000.dp).background(Color.Red).focusRequester(focusRequester).focusTarget().onKeyEvent { | ||
println("" + it.key + " " + it.type) |
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'd rather have test for all printable symbols - like sendKey(Key.Something) => actual value of the input is something
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 prefer to explicitly test 'onKeyEvent' here and the values of key event.
Changed the tests to check A..Z, 0..9 range.
The test for: JetBrains/compose-multiplatform#3644
Also a test for onPreviewKeyEvent issue (JetBrains/compose-multiplatform#2296)