Skip to content

Commit

Permalink
deps: Update svelte version
Browse files Browse the repository at this point in the history
Fix accessibility warnings:
- no role for canvas
- Custom legend items are now buttons (can be focused and react to keydown.enter event)
  • Loading branch information
KevinFabre-ods committed Nov 17, 2023
1 parent b082b66 commit 89db972
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 15 deletions.
14 changes: 7 additions & 7 deletions packages/visualizations/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/visualizations/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
"rollup-plugin-svelte": "^6.1.0",
"rollup-plugin-terser": "^7.0.2",
"rollup-plugin-visualizer": "^4.2.0",
"svelte": "^3.43.2",
"svelte": "^3.59.2",
"svelte-check": "^2.2.7",
"svelte-preprocess": "^4.9.8",
"tslib": "^2.0.3",
Expand Down
1 change: 0 additions & 1 deletion packages/visualizations/src/components/Chart/Chart.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,6 @@
{/if}
<figure class="chart legend--{legendPosition}">
<canvas
role="img"
use:chartJs={chartConfig}
aria-describedby={options.description ? chartId : undefined}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,20 @@
export let toggleSerie: (index: number) => void;
export let refined: boolean;
function handleOnClick() {
if (item.onClick) {
toggleSerie(itemIndex);
item.onClick(itemIndex);
}
}
function handleOnKeyDown(e: KeyboardEvent) {
if (item.onClick && e.key === 'Enter') {
toggleSerie(itemIndex);
item.onClick(itemIndex);
}
}
$: stringLabel =
item.label &&
(typeof item.label === 'string' ? item.label : item?.label?.text?.(itemIndex));
Expand All @@ -16,12 +30,10 @@
<div
class:refined
style="--cursor-style: {item.onClick ? 'pointer' : 'default'};"
on:click={() => {
if (item.onClick) {
toggleSerie(itemIndex);
item.onClick?.(itemIndex);
}
}}
role="button"
tabindex={item.onClick ? 0 : -1}
on:click={handleOnClick}
on:keydown={handleOnKeyDown}
on:mouseenter={() => {
if (item.onHover) {
item.onHover(itemIndex, !refined);
Expand Down

0 comments on commit 89db972

Please sign in to comment.