fix: fix question mark hotkey (#887)

* fix: fix question mark hotkey

* fix tests
issue-759
Nolan Lawson 2019-01-13 14:02:01 -08:00 zatwierdzone przez GitHub
rodzic 29a2892dd0
commit 6d1bb64bbb
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
2 zmienionych plików z 21 dodań i 12 usunięć

Wyświetl plik

@ -166,16 +166,14 @@ function unmapKeys (keyMap, keys, component) {
}
function acceptShortcutEvent (event) {
if (event.metaKey || event.ctrlKey || event.shiftKey) {
return
}
let target = event.target
if (target && (target.isContentEditable ||
target.tagName === 'INPUT' ||
target.tagName === 'TEXTAREA' ||
target.tagName === 'SELECT')) {
return false
}
return true
let { target } = event
return !(
event.metaKey ||
event.ctrlKey ||
(event.shiftKey && event.key !== '?') || // '?' is a special case - it is allowed
(target && (
target.isContentEditable ||
['INPUT', 'TEXTAREA', 'SELECT'].includes(target.tagName)
))
)
}

Wyświetl plik

@ -116,6 +116,17 @@ describe('test-shortcuts.js', function () {
assert.ok(component.notPressed())
})
it('does not skip events for ?', function () {
let component = new Component()
addToShortcutScope('global', '?', component)
let qEvent = new KeyDownEvent('?')
qEvent.shiftKey = true
eventListener(qEvent)
assert.ok(component.pressed())
})
it('skips events for editable elements', function () {
let component = new Component()