From 3995d9d201e2178b907255cca2edb1f67a771ddd Mon Sep 17 00:00:00 2001 From: Andrew Leach Date: Thu, 22 Feb 2024 15:30:36 +0000 Subject: [PATCH] PR feedback --- src/index.ts | 6 +++--- test/test.js | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/index.ts b/src/index.ts index 4aedb2a..ffecb05 100644 --- a/src/index.ts +++ b/src/index.ts @@ -5,7 +5,7 @@ export type ComboboxSettings = { } // Indicates the default behaviour for the first option when the list is shown. -export type FirstOptionSelectionMode = 'none' | 'selected' | 'focused' +export type FirstOptionSelectionMode = 'none' | 'active' | 'selected' export default class Combobox { isComposing: boolean @@ -81,7 +81,7 @@ export default class Combobox { } indicateDefaultOption(): void { - if (this.firstOptionSelectionMode === 'selected') { + if (this.firstOptionSelectionMode === 'active') { Array.from(this.list.querySelectorAll('[role="option"]:not([aria-disabled="true"])')) .filter(visible)[0] ?.setAttribute('data-combobox-option-default', 'true') @@ -89,7 +89,7 @@ export default class Combobox { } focusDefaultOptionIfNeeded(): void { - if (this.firstOptionSelectionMode === 'focused') { + if (this.firstOptionSelectionMode === 'selected') { this.navigate(1) } } diff --git a/test/test.js b/test/test.js index 5f47f13..3368cce 100644 --- a/test/test.js +++ b/test/test.js @@ -242,7 +242,7 @@ describe('combobox-nav', function () { }) }) - describe('with defaulting to first option', function () { + describe('with defaulting to the first option being active', function () { let input let list let options @@ -263,7 +263,7 @@ describe('combobox-nav', function () { input = document.querySelector('input') list = document.querySelector('ul') options = document.querySelectorAll('[role=option]') - combobox = new Combobox(input, list, {firstOptionSelectionMode: 'selected'}) + combobox = new Combobox(input, list, {firstOptionSelectionMode: 'active'}) combobox.start() }) @@ -313,7 +313,7 @@ describe('combobox-nav', function () { }) }) - describe('with defaulting to focusing the first option', function () { + describe('with defaulting to the first option being selected', function () { let input let list let combobox @@ -332,7 +332,7 @@ describe('combobox-nav', function () { ` input = document.querySelector('input') list = document.querySelector('ul') - combobox = new Combobox(input, list, {firstOptionSelectionMode: 'focused'}) + combobox = new Combobox(input, list, {firstOptionSelectionMode: 'selected'}) combobox.start() })