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

Fix web key mappings #1249

Merged
merged 4 commits into from
Apr 9, 2024
Merged

Fix web key mappings #1249

merged 4 commits into from
Apr 9, 2024

Conversation

eymar
Copy link
Member

@eymar eymar commented Apr 9, 2024

The test for: JetBrains/compose-multiplatform#3644

Also a test for onPreviewKeyEvent issue (JetBrains/compose-multiplatform#2296)

@eymar eymar requested a review from Schahen April 9, 2024 10:28
Copy link
Collaborator

@Schahen Schahen left a 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)
Copy link
Collaborator

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?

Copy link
Member Author

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)
Copy link
Collaborator

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

Copy link
Member Author

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.

@eymar eymar merged commit e67488c into jb-main Apr 9, 2024
6 checks passed
@eymar eymar deleted the ok/add_test_for_keymapping_bug branch April 9, 2024 14:54
@MatkovIvan MatkovIvan changed the title Add a test and a reproducer for key mappings bug Fix web key mappings Apr 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants