Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Graph] Fix various a11y issues #54097

Merged
merged 18 commits into from
Jan 13, 2020
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
7f8244b
fix various a11y issues
flash1293 Jan 7, 2020
35679b7
Merge remote-tracking branch 'upstream/master' into graph/a11y
flash1293 Jan 7, 2020
bddc98c
Merge remote-tracking branch 'upstream/master' into graph/a11y
flash1293 Jan 8, 2020
9f6853f
fix additional a11y issues
flash1293 Jan 8, 2020
2c87d99
simplify table list view and fix heading structure for visualize and …
flash1293 Jan 8, 2020
c460819
fix unit tests
flash1293 Jan 8, 2020
579d769
Merge remote-tracking branch 'upstream/master' into graph/a11y
flash1293 Jan 10, 2020
f1502e2
Update src/plugins/kibana_react/public/table_list_view/table_list_vie…
flash1293 Jan 10, 2020
17bff7b
Update src/plugins/kibana_react/public/table_list_view/table_list_vie…
flash1293 Jan 10, 2020
18cc05a
Update x-pack/legacy/plugins/graph/public/angular/templates/index.html
flash1293 Jan 10, 2020
92e1b17
Update x-pack/legacy/plugins/graph/public/components/guidance_panel/g…
flash1293 Jan 10, 2020
173f8ac
Update x-pack/legacy/plugins/graph/public/angular/templates/_sidebar.…
flash1293 Jan 10, 2020
71f7ecc
Merge branch 'graph/a11y' of github.com:flash1293/kibana into graph/a11y
flash1293 Jan 10, 2020
3cd3ed5
fix a11y of no data page
flash1293 Jan 10, 2020
e9bf311
Merge remote-tracking branch 'upstream/master' into graph/a11y
flash1293 Jan 10, 2020
0554990
only show labelled-by if listing content is already fetched
flash1293 Jan 10, 2020
1cc7a0d
fix table list view labelledby attribute during loading
flash1293 Jan 10, 2020
e6c1c89
Merge branch 'master' into graph/a11y
elasticmachine Jan 13, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ export interface TableListViewProps {
tableListTitle: string;
toastNotifications: ToastsStart;
uiSettings: IUiSettingsClient;
ariaDescribedby?: string;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TableListView already takes in quite a few textual inputs (entityName, entityNamePlural, tableListTitle).
Could those be used for this?

If the fact they are translated is an issue, I would still pass in a single input, instead of the two added here (ariaDescribedby, headingId)?.

Also, TableListView is used in only two other places. Would you mind adding this new attribute (if eventually needed) there as well?

Copy link
Contributor Author

@flash1293 flash1293 Jan 8, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason I introduced new properties is that in some cases the same id has to be used outside of the component - reusing the entity name seems like too much magic. I'm fine with just using a single property - it takes away some flexibility in using the component, but for the current usage it's not relevant.

headingId?: string;
}

export interface TableListViewState {
Expand Down Expand Up @@ -463,7 +465,7 @@ class TableListView extends React.Component<TableListViewProps, TableListViewSta
<EuiFlexGroup justifyContent="spaceBetween" alignItems="flexEnd" data-test-subj="top-nav">
<EuiFlexItem grow={false}>
<EuiTitle size="l">
<h1>{this.props.tableListTitle}</h1>
<h1 id={this.props.headingId}>{this.props.tableListTitle}</h1>
</EuiTitle>
</EuiFlexItem>

Expand Down Expand Up @@ -498,7 +500,9 @@ class TableListView extends React.Component<TableListViewProps, TableListViewSta
className="itemListing__page"
restrictWidth
>
<EuiPageBody>{this.renderPageContent()}</EuiPageBody>
<EuiPageBody aria-describedby={this.props.ariaDescribedby}>
{this.renderPageContent()}
</EuiPageBody>
</EuiPage>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

.help-block {
font-size: $euiFontSizeXS;
color: $euiColorDarkShade;
flash1293 marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down
14 changes: 12 additions & 2 deletions x-pack/legacy/plugins/graph/public/angular/templates/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div id="graphBasic" ng-controller="graphuiPlugin">
<main id="graphBasic" ng-controller="graphuiPlugin" aria-describedby="graphHeading">
flash1293 marked this conversation as resolved.
Show resolved Hide resolved
<!-- Local nav. -->
<kbn-top-nav name="workspacesTopNav" config="topNavMenu">
</kbn-top-nav>
Expand Down Expand Up @@ -81,6 +81,7 @@
<button
class="kuiButton kuiButton--basic kuiButton--small"
tooltip="{{ ::'xpack.graph.sidebar.topMenu.undoButtonTooltip' | i18n: { defaultMessage: 'Undo' } }}"
aria-label="{{ ::'xpack.graph.sidebar.topMenu.undoButtonTooltip' | i18n: { defaultMessage: 'Undo' } }}"
type="button"
ng-click="workspace.undo()"
ng-disabled="workspace === null||workspace.undoLog.length <1"
Expand All @@ -91,6 +92,7 @@
<button
class="kuiButton kuiButton--basic kuiButton--small"
tooltip="{{ ::'xpack.graph.sidebar.topMenu.redoButtonTooltip' | i18n: { defaultMessage: 'Redo' } }}"
aria-label="{{ ::'xpack.graph.sidebar.topMenu.redoButtonTooltip' | i18n: { defaultMessage: 'Redo' } }}"
type="button"
ng-disabled="workspace === null ||workspace.redoLog.length === 0"
ng-click="workspace.redo()"
Expand All @@ -100,48 +102,56 @@

<button class="kuiButton kuiButton--basic kuiButton--small" ng-disabled="workspace === null ||liveResponseFields.length === 0||workspace.nodes.length === 0"
tooltip="{{ ::'xpack.graph.sidebar.topMenu.expandSelectionButtonTooltip' | i18n: { defaultMessage: 'Expand selection' } }}"
aria-label="{{ ::'xpack.graph.sidebar.topMenu.expandSelectionButtonTooltip' | i18n: { defaultMessage: 'Expand selection' } }}"
ng-click="setDetail(null);workspace.expandSelecteds({toFields:liveResponseFields});">
<span class="kuiIcon fa-plus"></span>
</button>

<button class="kuiButton kuiButton--basic kuiButton--small" ng-disabled="workspace === null ||workspace.nodes.length === 0"
tooltip="{{ ::'xpack.graph.sidebar.topMenu.addLinksButtonTooltip' | i18n: { defaultMessage: 'Add links between existing terms' } }}"
aria-label="{{ ::'xpack.graph.sidebar.topMenu.addLinksButtonTooltip' | i18n: { defaultMessage: 'Add links between existing terms' } }}"
ng-click="workspace.fillInGraph();">
<span class="kuiIcon fa-link"></span>
</button>

<button class="kuiButton kuiButton--basic kuiButton--small" ng-disabled="workspace === null ||workspace.nodes.length === 0"
tooltip="{{ ::'xpack.graph.sidebar.topMenu.removeVerticesButtonTooltip' | i18n: { defaultMessage: 'Remove vertices from workspace' } }}"
aria-label="{{ ::'xpack.graph.sidebar.topMenu.removeVerticesButtonTooltip' | i18n: { defaultMessage: 'Remove vertices from workspace' } }}"
ng-click="setDetail(null);workspace.deleteSelection();" data-test-subj="graphRemoveSelection">
<span class="kuiIcon fa-trash"></span>
</button>

<button class="kuiButton kuiButton--basic kuiButton--small" ng-disabled="workspace === null ||workspace.selectedNodes.length === 0"
tooltip="{{ ::'xpack.graph.sidebar.topMenu.blacklistButtonTooltip' | i18n: { defaultMessage: 'Blacklist selection from return to workspace' } }}"
aria-label="{{ ::'xpack.graph.sidebar.topMenu.blacklistButtonTooltip' | i18n: { defaultMessage: 'Blacklist selection from return to workspace' } }}"
ng-click="workspace.blacklistSelection();">
<span class="kuiIcon fa-ban"></span>
</button>

<button class="kuiButton kuiButton--basic kuiButton--small" ng-disabled="workspace === null ||workspace.selectedNodes.length === 0"
tooltip="{{ ::'xpack.graph.sidebar.topMenu.customStyleButtonTooltip' | i18n: { defaultMessage: 'Custom style selected vertices' } }}"
aria-label="{{ ::'xpack.graph.sidebar.topMenu.customStyleButtonTooltip' | i18n: { defaultMessage: 'Custom style selected vertices' } }}"
ng-click="setDetail({showStyle:true})">
<span class="kuiIcon fa-paint-brush"></span>
</button>

<button class="kuiButton kuiButton--basic kuiButton--small" ng-disabled="workspace === null||workspace.nodes.length === 0"
tooltip="{{ ::'xpack.graph.sidebar.topMenu.drillDownButtonTooltip' | i18n: { defaultMessage: 'Drill down' } }}"
aria-label="{{ ::'xpack.graph.sidebar.topMenu.drillDownButtonTooltip' | i18n: { defaultMessage: 'Drill down' } }}"
ng-click="setDetail({showDrillDowns:true})">
<span class="kuiIcon fa-info"></span>
</button>

<button class="kuiButton kuiButton--basic kuiButton--small" ng-disabled="workspace.nodes.length === 0" ng-if="workspace.nodes.length === 0||workspace.force === null"
tooltip="{{ ::'xpack.graph.sidebar.topMenu.runLayoutButtonTooltip' | i18n: { defaultMessage: 'Run layout' } }}"
aria-label="{{ ::'xpack.graph.sidebar.topMenu.runLayoutButtonTooltip' | i18n: { defaultMessage: 'Run layout' } }}"
ng-click="workspace.runLayout()" data-test-subj="graphResumeLayout">
<span class="kuiIcon fa-play"></span>
</button>

<button class="kuiButton kuiButton--basic kuiButton--small" ng-if="workspace.force !== null&&workspace.nodes.length>0"
tooltip="{{ ::'xpack.graph.sidebar.topMenu.pauseLayoutButtonTooltip' | i18n: { defaultMessage: 'Pause layout' } }}"
aria-label="{{ ::'xpack.graph.sidebar.topMenu.pauseLayoutButtonTooltip' | i18n: { defaultMessage: 'Pause layout' } }}"
ng-click="workspace.stopLayout()" data-test-subj="graphPauseLayout">
<span class="kuiIcon fa-pause"></span>
</button>
Expand Down Expand Up @@ -386,4 +396,4 @@
</div>
<!--end svg container-->

</div>
</main>
2 changes: 2 additions & 0 deletions x-pack/legacy/plugins/graph/public/components/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { FieldManager } from './field_manager';
import { SearchBarProps, SearchBar } from './search_bar';
import { GraphStore } from '../state_management';
import { GuidancePanel } from './guidance_panel';
import { GraphTitle } from './graph_title';

import { KibanaContextProvider } from '../../../../../../src/plugins/kibana_react/public';

Expand Down Expand Up @@ -52,6 +53,7 @@ export function GraphApp(props: GraphAppProps) {
>
<Provider store={reduxStore}>
<>
{props.isInitialized && <GraphTitle />}
<div className="gphGraph__bar">
<SearchBar {...searchBarProps} />
<EuiSpacer size="s" />
Expand Down
26 changes: 26 additions & 0 deletions x-pack/legacy/plugins/graph/public/components/graph_title.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { connect } from 'react-redux';
import { EuiScreenReaderOnly } from '@elastic/eui';
import React from 'react';

import { GraphState, metaDataSelector } from '../state_management';

interface GraphTitleProps {
title: string;
}

/**
* Component showing the title of the current workspace as a heading visible for screen readers
*/
export const GraphTitle = connect<GraphTitleProps, {}, {}, GraphState>((state: GraphState) => ({
title: metaDataSelector(state).title,
}))(({ title }: GraphTitleProps) => (
<EuiScreenReaderOnly>
<h1 id="graphHeading">{title}</h1>
</EuiScreenReaderOnly>
));
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,10 @@
position: relative;
padding-left: $euiSizeXL;
margin-bottom: $euiSizeL;

button {
// make buttons wrap lines like regular text
display: contents;
}
}

.gphGuidancePanel__item--disabled {
color: $euiColorDarkShade;
pointer-events: none;

button {
color: $euiColorDarkShade !important;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ function ListItem({
'gphGuidancePanel__item--disabled': state === 'disabled',
})}
aria-disabled={state === 'disabled'}
aria-current={state === 'active' ? 'step' : undefined}
>
{state !== 'disabled' && (
<span
Expand Down Expand Up @@ -96,15 +97,15 @@ function GuidancePanelComponent(props: GuidancePanelProps) {
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiText>
<h1>
<h1 id="graphHeading">
{i18n.translate('xpack.graph.guidancePanel.title', {
defaultMessage: 'Three steps to your graph',
})}
</h1>
</EuiText>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<ul className="gphGuidancePanel__list">
<ol className="gphGuidancePanel__list" aria-describedby="graphHeading">
flash1293 marked this conversation as resolved.
Show resolved Hide resolved
<ListItem state={hasDatasource ? 'done' : 'active'}>
<EuiLink onClick={onOpenDatasourcePicker}>
{i18n.translate(
Expand All @@ -116,7 +117,7 @@ function GuidancePanelComponent(props: GuidancePanelProps) {
</EuiLink>
</ListItem>
<ListItem state={hasFields ? 'done' : hasDatasource ? 'active' : 'disabled'}>
<EuiLink onClick={onOpenFieldPicker}>
<EuiLink onClick={onOpenFieldPicker} disabled={!hasFields && !hasDatasource}>
{i18n.translate('xpack.graph.guidancePanel.fieldsItem.fieldsButtonLabel', {
defaultMessage: 'Add fields.',
})}
Expand All @@ -128,7 +129,7 @@ function GuidancePanelComponent(props: GuidancePanelProps) {
defaultMessage="Enter a query in the search bar to start exploring. Don't know where to start? {topTerms}."
values={{
topTerms: (
<EuiLink onClick={onFillWorkspace}>
<EuiLink onClick={onFillWorkspace} disabled={!hasFields}>
{i18n.translate('xpack.graph.guidancePanel.nodesItem.topTermsButtonLabel', {
defaultMessage: 'Graph the top terms',
})}
Expand All @@ -137,7 +138,7 @@ function GuidancePanelComponent(props: GuidancePanelProps) {
}}
/>
</ListItem>
</ul>
</ol>
</EuiFlexItem>
</EuiFlexGroup>
</EuiPanel>
Expand Down
12 changes: 7 additions & 5 deletions x-pack/legacy/plugins/graph/public/components/listing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ export function Listing(props: ListingProps) {
return (
<I18nProvider>
<TableListView
ariaDescribedby="graphListingHeading"
headingId="graphListingHeading"
createItem={props.capabilities.save ? props.createItem : undefined}
findItems={props.findItems}
deleteItems={props.capabilities.delete ? props.deleteItems : undefined}
Expand Down Expand Up @@ -67,14 +69,14 @@ function getNoItemsMessage(
return (
<div>
<EuiEmptyPrompt
iconType="visualizeApp"
iconType="graphApp"
title={
<h2>
<h1 id="graphListingHeading">
<FormattedMessage
id="xpack.graph.listing.noItemsMessage"
defaultMessage="Looks like you don't have any graphs."
/>
</h2>
</h1>
}
/>
</div>
Expand All @@ -88,12 +90,12 @@ function getNoItemsMessage(
<EuiEmptyPrompt
iconType="graphApp"
title={
<h2>
<h1 id="graphListingHeading">
<FormattedMessage
id="xpack.graph.listing.createNewGraph.title"
defaultMessage="Create your first graph"
/>
</h2>
</h1>
}
body={
<Fragment>
Expand Down