Skip to content

Commit 6d99924

Browse files
committed
fix(a11y): address review comments on stateless buttons and explicit labels
1 parent f14d880 commit 6d99924

File tree

1 file changed

+22
-23
lines changed

1 file changed

+22
-23
lines changed

app/components/Compare/FacetSelector.vue

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -25,45 +25,43 @@ function isCategoryNoneSelected(category: string): boolean {
2525
</script>
2626

2727
<template>
28-
<div class="space-y-3" role="group" :aria-label="$t('compare.facets.group_label')">
28+
<div class="space-y-3">
2929
<div v-for="category in categoryOrder" :key="category">
30-
<!-- Category header with all/none buttons -->
31-
<div
32-
class="flex items-center gap-2 mb-2"
33-
:aria-labelledby="`facet-category-label-${category}`"
34-
>
30+
<div class="flex items-center gap-2 mb-2">
3531
<span
3632
:id="`facet-category-label-${category}`"
3733
class="text-3xs text-fg-subtle uppercase tracking-wider"
3834
>
3935
{{ getCategoryLabel(category) }}
4036
</span>
37+
4138
<ButtonBase
42-
role="radio"
43-
:aria-checked="isCategoryAllSelected(category)"
44-
:tabindex="getCategoryActiveControl(category) === 'all' ? 0 : -1"
45-
data-radio-type="all"
46-
@keydown="handleCategoryControlKeydown(category, $event)"
47-
@click="selectCategory(category)"
4839
size="sm"
40+
data-facet-category-action="all"
41+
:data-facet-category="category"
42+
:aria-label="`${$t('compare.facets.all')} ${getCategoryLabel(category)}`"
43+
:aria-disabled="isCategoryAllSelected(category)"
44+
:class="{ 'opacity-40 cursor-not-allowed border-transparent': isCategoryAllSelected(category) }"
45+
@click="!isCategoryAllSelected(category) && selectCategory(category)"
4946
>
5047
{{ $t('compare.facets.all') }}
5148
</ButtonBase>
49+
5250
<span class="text-2xs text-fg-muted/40" aria-hidden="true">/</span>
51+
5352
<ButtonBase
54-
role="radio"
55-
:aria-checked="isCategoryNoneSelected(category)"
56-
:tabindex="getCategoryActiveControl(category) === 'none' ? 0 : -1"
57-
data-radio-type="none"
58-
@keydown="handleCategoryControlKeydown(category, $event)"
59-
@click="deselectCategory(category)"
6053
size="sm"
54+
data-facet-category-action="none"
55+
:data-facet-category="category"
56+
:aria-label="`${$t('compare.facets.none')} ${getCategoryLabel(category)}`"
57+
:aria-disabled="isCategoryNoneSelected(category)"
58+
:class="{ 'opacity-40 cursor-not-allowed border-transparent': isCategoryNoneSelected(category) }"
59+
@click="!isCategoryNoneSelected(category) && deselectCategory(category)"
6160
>
6261
{{ $t('compare.facets.none') }}
6362
</ButtonBase>
6463
</div>
6564

66-
<!-- Facet buttons -->
6765
<div
6866
class="flex items-center gap-1.5 flex-wrap"
6967
role="group"
@@ -74,11 +72,12 @@ function isCategoryNoneSelected(category: string): boolean {
7472
v-for="facet in facetsByCategory[category]"
7573
:key="facet.id"
7674
size="sm"
77-
:title="facet.comingSoon ? $t('compare.facets.coming_soon') : facet.description"
78-
:aria-disabled="facet.comingSoon"
7975
role="checkbox"
76+
:title="facet.comingSoon ? $t('compare.facets.coming_soon') : facet.description"
77+
:disabled="facet.comingSoon"
8078
:aria-checked="isFacetSelected(facet.id)"
81-
class="gap-1 px-1.5 rounded transition-colors"
79+
:aria-label="facet.label"
80+
class="gap-1 px-1.5 rounded transition-colors focus-visible:outline-accent/70"
8281
:class="
8382
facet.comingSoon
8483
? 'text-fg-subtle/50 bg-bg-subtle border-border-subtle cursor-not-allowed'
@@ -103,4 +102,4 @@ function isCategoryNoneSelected(category: string): boolean {
103102
</div>
104103
</div>
105104
</div>
106-
</template>
105+
</template>

0 commit comments

Comments
 (0)