Skip to content

Commit 3995d9d

Browse files
author
Andrew Leach
committed
PR feedback
1 parent c28985b commit 3995d9d

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export type ComboboxSettings = {
55
}
66

77
// Indicates the default behaviour for the first option when the list is shown.
8-
export type FirstOptionSelectionMode = 'none' | 'selected' | 'focused'
8+
export type FirstOptionSelectionMode = 'none' | 'active' | 'selected'
99

1010
export default class Combobox {
1111
isComposing: boolean
@@ -81,15 +81,15 @@ export default class Combobox {
8181
}
8282

8383
indicateDefaultOption(): void {
84-
if (this.firstOptionSelectionMode === 'selected') {
84+
if (this.firstOptionSelectionMode === 'active') {
8585
Array.from(this.list.querySelectorAll<HTMLElement>('[role="option"]:not([aria-disabled="true"])'))
8686
.filter(visible)[0]
8787
?.setAttribute('data-combobox-option-default', 'true')
8888
}
8989
}
9090

9191
focusDefaultOptionIfNeeded(): void {
92-
if (this.firstOptionSelectionMode === 'focused') {
92+
if (this.firstOptionSelectionMode === 'selected') {
9393
this.navigate(1)
9494
}
9595
}

test/test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ describe('combobox-nav', function () {
242242
})
243243
})
244244

245-
describe('with defaulting to first option', function () {
245+
describe('with defaulting to the first option being active', function () {
246246
let input
247247
let list
248248
let options
@@ -263,7 +263,7 @@ describe('combobox-nav', function () {
263263
input = document.querySelector('input')
264264
list = document.querySelector('ul')
265265
options = document.querySelectorAll('[role=option]')
266-
combobox = new Combobox(input, list, {firstOptionSelectionMode: 'selected'})
266+
combobox = new Combobox(input, list, {firstOptionSelectionMode: 'active'})
267267
combobox.start()
268268
})
269269

@@ -313,7 +313,7 @@ describe('combobox-nav', function () {
313313
})
314314
})
315315

316-
describe('with defaulting to focusing the first option', function () {
316+
describe('with defaulting to the first option being selected', function () {
317317
let input
318318
let list
319319
let combobox
@@ -332,7 +332,7 @@ describe('combobox-nav', function () {
332332
`
333333
input = document.querySelector('input')
334334
list = document.querySelector('ul')
335-
combobox = new Combobox(input, list, {firstOptionSelectionMode: 'focused'})
335+
combobox = new Combobox(input, list, {firstOptionSelectionMode: 'selected'})
336336
combobox.start()
337337
})
338338

0 commit comments

Comments
 (0)