Skip to content

Commit

Permalink
fix(a11y): Category legend items are now accessible
Browse files Browse the repository at this point in the history
- Can be focused
- A "Enter" key down enter, activate them
  • Loading branch information
KevinFabre-ods committed Dec 6, 2023
1 parent de9610d commit c11c6f0
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,23 @@
export let toggleSerie: (index: number) => void;
export let refined: boolean;
const onKeyDown = (event: KeyboardEvent) => {
if (event.key !== 'Enter' || !item.onClick) return;
toggleSerie(itemIndex);
item.onClick(itemIndex);
};
$: stringLabel =
item.label &&
(typeof item.label === 'string' ? item.label : item?.label?.text?.(itemIndex));
</script>

<div
role="button"
tabindex={item.onClick ? 0 : -1}
class:refined
style="--cursor-style: {item.onClick ? 'pointer' : 'default'};"
on:keydown={onKeyDown}
on:click={() => {
if (item.onClick) {
toggleSerie(itemIndex);
Expand Down

0 comments on commit c11c6f0

Please sign in to comment.