Skip to content

Commit 4a39083

Browse files
committed
fix(a11y): fix typescript types and remove unused i18n keys
1 parent ec535ea commit 4a39083

File tree

3 files changed

+15
-16
lines changed

3 files changed

+15
-16
lines changed

app/components/Compare/FacetSelector.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ function handleCategoryControlKeydown(category: string, event: KeyboardEvent): v
6464
}
6565
6666
const nextRadio = radios[nextIndex]
67+
if (!nextRadio) return
6768
const radioType = nextRadio.dataset.radioType
6869
6970
if (radioType === 'all') {
@@ -98,7 +99,7 @@ function handleCategoryControlKeydown(category: string, event: KeyboardEvent): v
9899
:aria-disabled="isCategoryAllSelected(category)"
99100
:tabindex="getCategoryActiveControl(category) === 'all' ? 0 : -1"
100101
data-radio-type="all"
101-
@keydown="event => handleCategoryControlKeydown(category, event)"
102+
@keydown="handleCategoryControlKeydown(category, $event)"
102103
@click="selectCategory(category)"
103104
size="small"
104105
>
@@ -111,7 +112,7 @@ function handleCategoryControlKeydown(category: string, event: KeyboardEvent): v
111112
:aria-disabled="isCategoryNoneSelected(category)"
112113
:tabindex="getCategoryActiveControl(category) === 'none' ? 0 : -1"
113114
data-radio-type="none"
114-
@keydown="event => handleCategoryControlKeydown(category, event)"
115+
@keydown="handleCategoryControlKeydown(category, $event)"
115116
@click="deselectCategory(category)"
116117
size="small"
117118
>

i18n/locales/en.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,8 +1081,6 @@
10811081
"coming_soon": "Coming soon",
10821082
"select_all": "Select all facets",
10831083
"deselect_all": "Deselect all facets",
1084-
"select_category": "Select all {category} facets",
1085-
"deselect_category": "Deselect all {category} facets",
10861084
"binary_only_tooltip": "This package exposes binaries and no exports",
10871085
"categories": {
10881086
"performance": "Performance",

test/nuxt/components/compare/FacetSelector.spec.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -191,10 +191,10 @@ describe('FacetSelector', () => {
191191
const component = await mountSuspended(FacetSelector)
192192

193193
// totalDependencies is marked as comingSoon
194-
const buttons = component.findAll('button')
194+
const buttons = component.findAll('button[role="checkbox"]')
195195
const comingSoonButton = buttons.find(b => b.text().includes(comingSoonFacetLabel))
196196

197-
expect(comingSoonButton?.attributes('disabled')).toBeDefined()
197+
expect(comingSoonButton?.attributes('aria-disabled')).toBe('true')
198198
})
199199

200200
it('shows coming soon text for comingSoon facets', async () => {
@@ -231,8 +231,8 @@ describe('FacetSelector', () => {
231231
it('calls selectCategory when all button is clicked', async () => {
232232
const component = await mountSuspended(FacetSelector)
233233

234-
// Find the first 'all' button (for performance category)
235-
const allButton = component.findAll('button').find(b => b.text() === 'all')
234+
// Find the first 'all' radio (for performance category)
235+
const allButton = component.findAll('button[role="radio"]').find(b => b.text() === 'all')
236236
await allButton!.trigger('click')
237237

238238
expect(mockSelectCategory).toHaveBeenCalledWith('performance')
@@ -245,8 +245,8 @@ describe('FacetSelector', () => {
245245

246246
const component = await mountSuspended(FacetSelector)
247247

248-
// Find the first 'none' button (for performance category)
249-
const noneButton = component.findAll('button').find(b => b.text() === 'none')
248+
// Find the first 'none' radio (for performance category)
249+
const noneButton = component.findAll('button[role="radio"]').find(b => b.text() === 'none')
250250
await noneButton!.trigger('click')
251251

252252
expect(mockDeselectCategory).toHaveBeenCalledWith('performance')
@@ -262,9 +262,9 @@ describe('FacetSelector', () => {
262262

263263
const component = await mountSuspended(FacetSelector)
264264

265-
const allButton = component.findAll('button').find(b => b.text() === 'all')
266-
// First all button (performance) should be disabled
267-
expect(allButton!.attributes('disabled')).toBeDefined()
265+
const allButton = component.findAll('button[role="radio"]').find(b => b.text() === 'all')
266+
// First all button (performance) should be aria-disabled
267+
expect(allButton!.attributes('aria-disabled')).toBe('true')
268268
})
269269

270270
it('disables none button when no facets in category are selected', async () => {
@@ -274,9 +274,9 @@ describe('FacetSelector', () => {
274274

275275
const component = await mountSuspended(FacetSelector)
276276

277-
const noneButton = component.findAll('button').find(b => b.text() === 'none')
278-
// First none button (performance) should be disabled
279-
expect(noneButton!.attributes('disabled')).toBeDefined()
277+
const noneButton = component.findAll('button[role="radio"]').find(b => b.text() === 'none')
278+
// First none button (performance) should be aria-disabled
279+
expect(noneButton!.attributes('aria-disabled')).toBe('true')
280280
})
281281
})
282282

0 commit comments

Comments
 (0)