Skip to content

Commit d4ff922

Browse files
muandgraham
andcommitted
Return early for oses without ctrlBindings
Co-authored-by: David Graham <[email protected]>
1 parent 4b6ba92 commit d4ff922

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ export default class Combobox {
9999

100100
function keyboardBindings(event: KeyboardEvent, combobox: Combobox) {
101101
if (event.shiftKey || event.metaKey || event.altKey) return
102+
if (!ctrlBindings && event.ctrlKey) return
102103
if (combobox.isComposing) return
103104

104105
switch (event.key) {
@@ -132,7 +133,7 @@ function keyboardBindings(event: KeyboardEvent, combobox: Combobox) {
132133
}
133134
break
134135
default:
135-
if (ctrlBindings && event.ctrlKey) break
136+
if (event.ctrlKey) break
136137
combobox.clearSelection()
137138
}
138139
}

test/test.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,11 +173,9 @@ describe('combobox-nav', function() {
173173
assert.equal(options[0].getAttribute('aria-selected'), 'true')
174174
assert.equal(input.getAttribute('aria-activedescendant'), 'baymax')
175175

176-
if (ctrlBindings) {
177-
press(input, 'Control', true)
178-
assert.equal(options[0].getAttribute('aria-selected'), 'true', 'Selection stays on modifier keydown')
179-
assert.equal(input.getAttribute('aria-activedescendant'), 'baymax', 'Selection stays on modifier keydown')
180-
}
176+
press(input, 'Control', true)
177+
assert.equal(options[0].getAttribute('aria-selected'), 'true', 'Selection stays on modifier keydown')
178+
assert.equal(input.getAttribute('aria-activedescendant'), 'baymax', 'Selection stays on modifier keydown')
181179

182180
press(input, 'Backspace')
183181
assert(!list.querySelector('[aria-selected=true]'), 'Nothing should be selected')

0 commit comments

Comments
 (0)