Skip to content

Commit

Permalink
fix(xy): line annotation marker aria label fix (#2558)
Browse files Browse the repository at this point in the history
  • Loading branch information
rbrtj authored Nov 14, 2024
1 parent b283f92 commit 3b056c3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/charts/api/charts.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1927,6 +1927,7 @@ export const LineAnnotation: <D = any>(props: SFProps<LineAnnotationSpec<D>, key

// @public
export interface LineAnnotationDatum<D = any> {
ariaLabel?: string;
dataValue: D;
details?: string;
header?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ export function LineMarker({

void popper?.current?.update?.();

const ariaLabel = datum.ariaLabel ?? datum.details ?? datum.header ?? `line annotation ${datum.dataValue}`;

// want it to be tabbable if interactive if there is a click handler
return clickable ? (
<button
Expand All @@ -135,6 +137,7 @@ export function LineMarker({
onClick={onDOMElementClick}
style={{ ...markerStyle, ...transform }}
type="button"
aria-label={ariaLabel}
>
<div ref={iconRef} className="echAnnotation__icon">
{renderWithProps(icon, datum)}
Expand Down
4 changes: 4 additions & 0 deletions packages/charts/src/chart_types/xy_chart/utils/specs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -823,6 +823,10 @@ export interface LineAnnotationDatum<D = any> {
* An header of the annotation. If undefined, than the formatted dataValue will be used
*/
header?: string;
/**
* Aria label for the annotation
*/
ariaLabel?: string;
}

/** @public */
Expand Down

0 comments on commit 3b056c3

Please sign in to comment.