Skip to content

Commit d32d5bd

Browse files
authored
[Lens] (Accessibility) add aria-label to chart type icon (#84493) (#84517)
1 parent b552138 commit d32d5bd

3 files changed

Lines changed: 26 additions & 8 deletions

File tree

x-pack/plugins/lens/public/editor_frame_service/editor_frame/config_panel/layer_settings.tsx

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,21 @@ export function LayerSettings({
2626
return null;
2727
}
2828

29-
const a11yText = i18n.translate('xpack.lens.editLayerSettings', {
30-
defaultMessage: 'Edit layer settings',
31-
});
29+
const a11yText = (chartType?: string) => {
30+
if (chartType) {
31+
return i18n.translate('xpack.lens.editLayerSettingsChartType', {
32+
defaultMessage: 'Edit layer settings, {chartType}',
33+
values: {
34+
chartType,
35+
},
36+
});
37+
}
38+
return i18n.translate('xpack.lens.editLayerSettings', {
39+
defaultMessage: 'Edit layer settings',
40+
});
41+
};
3242

43+
const contextMenuIcon = activeVisualization.getLayerContextMenuIcon?.(layerConfigProps);
3344
return (
3445
<EuiPopover
3546
id={`lnsLayerPopover_${layerId}`}
@@ -43,9 +54,9 @@ export function LayerSettings({
4354
>
4455
<ToolbarButton
4556
size="s"
46-
iconType={activeVisualization.getLayerContextMenuIcon?.(layerConfigProps) || 'gear'}
47-
aria-label={a11yText}
48-
title={a11yText}
57+
iconType={contextMenuIcon?.icon || 'gear'}
58+
aria-label={a11yText(contextMenuIcon?.label || '')}
59+
title={a11yText(contextMenuIcon?.label || '')}
4960
onClick={() => setIsOpen(!isOpen)}
5061
data-test-subj="lns_layer_settings"
5162
/>

x-pack/plugins/lens/public/types.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,10 @@ export interface Visualization<T = unknown> {
540540
* Visualizations can provide a custom icon which will open a layer-specific popover
541541
* If no icon is provided, gear icon is default
542542
*/
543-
getLayerContextMenuIcon?: (opts: { state: T; layerId: string }) => IconType | undefined;
543+
getLayerContextMenuIcon?: (opts: {
544+
state: T;
545+
layerId: string;
546+
}) => { icon: IconType | 'gear'; label: string } | undefined;
544547

545548
/**
546549
* The frame is telling the visualization to update or set a dimension based on user interaction

x-pack/plugins/lens/public/xy_visualization/visualization.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,11 @@ export const getXyVisualization = ({
300300

301301
getLayerContextMenuIcon({ state, layerId }) {
302302
const layer = state.layers.find((l) => l.layerId === layerId);
303-
return visualizationTypes.find((t) => t.id === layer?.seriesType)?.icon;
303+
const visualizationType = visualizationTypes.find((t) => t.id === layer?.seriesType);
304+
return {
305+
icon: visualizationType?.icon || 'gear',
306+
label: visualizationType?.label || '',
307+
};
304308
},
305309

306310
renderLayerContextMenu(domElement, props) {

0 commit comments

Comments
 (0)