fix: fix question mark hotkey (#887)
* fix: fix question mark hotkey * fix tests
This commit is contained in:
parent
29a2892dd0
commit
6d1bb64bbb
|
@ -166,16 +166,14 @@ function unmapKeys (keyMap, keys, component) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function acceptShortcutEvent (event) {
|
function acceptShortcutEvent (event) {
|
||||||
if (event.metaKey || event.ctrlKey || event.shiftKey) {
|
let { target } = event
|
||||||
return
|
return !(
|
||||||
}
|
event.metaKey ||
|
||||||
|
event.ctrlKey ||
|
||||||
let target = event.target
|
(event.shiftKey && event.key !== '?') || // '?' is a special case - it is allowed
|
||||||
if (target && (target.isContentEditable ||
|
(target && (
|
||||||
target.tagName === 'INPUT' ||
|
target.isContentEditable ||
|
||||||
target.tagName === 'TEXTAREA' ||
|
['INPUT', 'TEXTAREA', 'SELECT'].includes(target.tagName)
|
||||||
target.tagName === 'SELECT')) {
|
))
|
||||||
return false
|
)
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,6 +116,17 @@ describe('test-shortcuts.js', function () {
|
||||||
assert.ok(component.notPressed())
|
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 () {
|
it('skips events for editable elements', function () {
|
||||||
let component = new Component()
|
let component = new Component()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue