Skip to content

Commit 828a983

Browse files
committed
fix: improve accessibility and fix minor bugs across components
- Fix gap=0 not being applied in FluxStack and FluxTableCell - Add missing v-for keys in FluxPercentageBar and FluxLegend - Add aria-labels to icon-only buttons (FluxRemove, FluxBadge, FluxTag, FluxNotice) - Add scope="col" to FluxTableHeader for screen reader support - Add aria-level to FluxTreeView tree items - Link tab panels with aria-labelledby/aria-controls in FluxTabs - Fix event propagation on delete buttons in FluxBadge and FluxTag - Change role="textbox" to role="group" in FluxFormInputGroup - Use semantic h3 for section title in FluxFormSection - Add direction prop to FluxDivider for dynamic aria-orientation - Add flux.close and flux.delete i18n keys
1 parent 7700a09 commit 828a983

15 files changed

Lines changed: 56 additions & 22 deletions

packages/components/src/component/FluxBadge.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@
4040
v-if="type === 'none' && isDeletable"
4141
:class="$style.badgeClose"
4242
type="button"
43-
@click="onDeleteClick()">
43+
:aria-label="translate('flux.delete')"
44+
@click.stop="onDeleteClick()">
4445
<FluxIcon name="xmark"/>
4546
</button>
4647
</FluxPressable>
@@ -51,6 +52,7 @@
5152
setup>
5253
import type { FluxButtonEmits, FluxColor, FluxIconName, FluxPressableType, FluxTo } from '@flux-ui/types';
5354
import { clsx } from 'clsx';
55+
import { useTranslate } from '$flux/composable/private';
5456
import FluxIcon from './FluxIcon.vue';
5557
import FluxPressable from './FluxPressable.vue';
5658
import FluxSpinner from './FluxSpinner.vue';
@@ -78,6 +80,8 @@
7880
readonly to?: FluxTo;
7981
}>();
8082
83+
const translate = useTranslate();
84+
8185
function onDeleteClick(): void {
8286
emit('delete');
8387
}

packages/components/src/component/FluxDivider.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
contentPlacement === 'end' && $style.dividerContentEnd
77
)"
88
role="separator"
9-
aria-orientation="horizontal">
9+
:aria-orientation="direction">
1010
<div
1111
v-if="slots.default"
1212
:class="$style.dividerContent">
@@ -22,13 +22,16 @@
2222
<script
2323
lang="ts"
2424
setup>
25+
import type { FluxDirection } from '@flux-ui/types';
2526
import { clsx } from 'clsx';
2627
import $style from '$flux/css/component/Divider.module.scss';
2728
2829
const {
29-
contentPlacement = 'center'
30+
contentPlacement = 'center',
31+
direction = 'horizontal'
3032
} = defineProps<{
3133
readonly contentPlacement?: 'start' | 'center' | 'end';
34+
readonly direction?: FluxDirection;
3235
}>();
3336
3437
const slots = defineSlots<{

packages/components/src/component/FluxFormInputGroup.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
isCondensed && $style.isCondensed,
66
isSecondary && $style.isSecondary
77
)"
8-
role="textbox">
8+
role="group">
99
<slot/>
1010
</div>
1111
</template>

packages/components/src/component/FluxFormSection.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<template>
22
<div :class="$style.formSection">
3-
<div :class="$style.formSectionTitle">
3+
<h3 :class="$style.formSectionTitle">
44
{{ title }}
5-
</div>
5+
</h3>
66

77
<slot/>
88
</div>

packages/components/src/component/FluxLegend.vue

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
<template>
22
<div :class="direction === 'horizontal' ? $style.legendHorizontal : $style.legendVertical">
3-
<template v-for="item of items">
4-
<span
5-
:class="$style.legendItem"
6-
:style="{
7-
'--color': item.color
8-
}">
9-
{{ item.label }}
10-
</span>
11-
</template>
3+
<span
4+
v-for="(item, index) of items"
5+
:key="index"
6+
:class="$style.legendItem"
7+
:style="{
8+
'--color': item.color
9+
}">
10+
{{ item.label }}
11+
</span>
1212
</div>
1313
</template>
1414

packages/components/src/component/FluxNotice.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
v-if="isCloseable"
4141
:class="$style.noticeClose"
4242
type="button"
43+
:aria-label="translate('flux.close')"
4344
@click="emit('close')">
4445
<FluxIcon name="xmark"/>
4546
</button>
@@ -51,6 +52,7 @@
5152
setup>
5253
import type { FluxColor, FluxIconName } from '@flux-ui/types';
5354
import { clsx } from 'clsx';
55+
import { useTranslate } from '$flux/composable/private';
5456
import FluxIcon from './FluxIcon.vue';
5557
import FluxSpinner from './FluxSpinner.vue';
5658
import $style from '$flux/css/component/Notice.module.scss';
@@ -76,4 +78,6 @@
7678
default(): any;
7779
end(): any;
7880
}>();
81+
82+
const translate = useTranslate();
7983
</script>

packages/components/src/component/FluxPercentageBar.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
<template>
22
<div :class="$style.percentageBar">
33
<div :class="$style.percentageBarTrack">
4-
<FluxTooltip v-for="item of items">
4+
<FluxTooltip
5+
v-for="(item, index) of items"
6+
:key="index">
57
<template #content>
68
<div :class="$style.percentageBarTooltip">
79
<FluxIcon

packages/components/src/component/FluxRemove.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
isHidden && $style.isHidden
66
)"
77
type="button"
8+
:aria-label="translate('flux.delete')"
89
@click="emit('click', $event)">
910
<FluxIcon
1011
v-if="icon"
@@ -18,6 +19,7 @@
1819
setup>
1920
import type { FluxIconName } from '@flux-ui/types';
2021
import { clsx } from 'clsx';
22+
import { useTranslate } from '$flux/composable/private';
2123
import FluxIcon from './FluxIcon.vue';
2224
import $style from '$flux/css/component/Remove.module.scss';
2325
@@ -31,4 +33,6 @@
3133
readonly icon?: FluxIconName;
3234
readonly isHidden?: boolean;
3335
}>();
36+
37+
const translate = useTranslate();
3438
</script>

packages/components/src/component/FluxStack.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
isWrapping && $style.isWrapping
1010
)"
1111
:style="{
12-
'--gap': gap && `${gap}px`
12+
'--gap': gap != null ? `${gap}px` : undefined
1313
}">
1414
<slot/>
1515
</Component>

packages/components/src/component/FluxTableCell.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
:class="$style.tableCellContent"
1414
:style="{
1515
flexFlow: contentDirection,
16-
gap: contentGap && `${contentGap}px`
16+
gap: contentGap != null ? `${contentGap}px` : undefined
1717
}">
1818
<slot/>
1919
</div>

0 commit comments

Comments
 (0)