chore(a11y): add role to wrapping g for edges
This commit is contained in:
@@ -202,7 +202,7 @@ export default (EdgeComponent: ComponentType<EdgeProps>) => {
|
|||||||
onMouseLeave={onEdgeMouseLeave}
|
onMouseLeave={onEdgeMouseLeave}
|
||||||
onKeyDown={isFocusable ? onKeyDown : undefined}
|
onKeyDown={isFocusable ? onKeyDown : undefined}
|
||||||
tabIndex={isFocusable ? 0 : undefined}
|
tabIndex={isFocusable ? 0 : undefined}
|
||||||
role={isFocusable ? 'button' : undefined}
|
role={isFocusable ? 'button' : 'img'}
|
||||||
data-testid={`rf__edge-${id}`}
|
data-testid={`rf__edge-${id}`}
|
||||||
aria-label={ariaLabel === null ? undefined : ariaLabel ? ariaLabel : `Edge from ${source} to ${target}`}
|
aria-label={ariaLabel === null ? undefined : ariaLabel ? ariaLabel : `Edge from ${source} to ${target}`}
|
||||||
aria-describedby={isFocusable ? `${ARIA_EDGE_DESC_KEY}-${rfId}` : undefined}
|
aria-describedby={isFocusable ? `${ARIA_EDGE_DESC_KEY}-${rfId}` : undefined}
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
export let targetY: $$Props['targetY'];
|
export let targetY: $$Props['targetY'];
|
||||||
export let sourcePosition: $$Props['sourcePosition'];
|
export let sourcePosition: $$Props['sourcePosition'];
|
||||||
export let targetPosition: $$Props['targetPosition'];
|
export let targetPosition: $$Props['targetPosition'];
|
||||||
|
export let ariaLabel: $$Props['ariaLabel'] = undefined;
|
||||||
// @ todo: support edge updates
|
// @ todo: support edge updates
|
||||||
|
|
||||||
const { edges, edgeTypes, flowId, addSelectedEdges } = useStore();
|
const { edges, edgeTypes, flowId, addSelectedEdges } = useStore();
|
||||||
@@ -51,7 +52,19 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
||||||
<g class="svelte-flow__edge" class:animated class:selected data-id={id} on:click={onClick}>
|
<g
|
||||||
|
class="svelte-flow__edge"
|
||||||
|
class:animated
|
||||||
|
class:selected
|
||||||
|
data-id={id}
|
||||||
|
on:click={onClick}
|
||||||
|
aria-label={ariaLabel === null
|
||||||
|
? undefined
|
||||||
|
: ariaLabel
|
||||||
|
? ariaLabel
|
||||||
|
: `Edge from ${source} to ${target}`}
|
||||||
|
role="img"
|
||||||
|
>
|
||||||
<svelte:component
|
<svelte:component
|
||||||
this={edgeComponent}
|
this={edgeComponent}
|
||||||
{id}
|
{id}
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ export type EdgeLayouted = Pick<
|
|||||||
| 'markerEnd'
|
| 'markerEnd'
|
||||||
| 'sourceHandle'
|
| 'sourceHandle'
|
||||||
| 'targetHandle'
|
| 'targetHandle'
|
||||||
|
| 'ariaLabel'
|
||||||
> &
|
> &
|
||||||
EdgePosition & {
|
EdgePosition & {
|
||||||
sourceHandleId?: string | null;
|
sourceHandleId?: string | null;
|
||||||
|
|||||||
Reference in New Issue
Block a user