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 emoji input on iOS #764

Merged
merged 3 commits into from
Aug 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/js/utils/key.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export default class Key {
if (this.isTab()) {
return TAB
}
return String.fromCharCode(this.charCode)
return String.fromCodePoint(this.charCode)
}

// See https://caniuse.com/#feat=keyboardevent-key for browser support.
Expand Down
12 changes: 12 additions & 0 deletions tests/unit/utils/key-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,15 @@ test('uses keyCode as a fallback if key is not supported', assert => {
keyInstance = Key.fromEvent(event)
assert.ok(keyInstance.isSpace(), 'keyCode is used if key is not supported')
})

test('properly handles UTF-16 characters', assert => {
let element = $('#qunit-fixture')[0]

let event = Helpers.dom.createMockEvent('keypress', element, {
key: '😀',
keyCode: 128512,
charCode: 128512,
})
let keyInstance = Key.fromEvent(event)
assert.equal('😀', keyInstance.toString(), 'emoji was not properly decoded')
})