Skip to content

Commit f587dc0

Browse files
authored
Improve Discover screen-reader accessibility: (#11598) (#11676)
- Apply aria-label to field name icons. - Change title to alt for Discover 'Back to top' link. - Remove unnecessary title attributes from Discover No Results state. - Add aria-label to Discover sidebar's string field value. - Adjust aria-label of Discover Field Chooser 'Show field settings' button.
1 parent 73e74b0 commit f587dc0

File tree

16 files changed

+114
-43
lines changed

16 files changed

+114
-43
lines changed

src/core_plugins/kibana/public/discover/components/field_chooser/field_chooser.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,11 @@ <h5>Available Fields
4545
></span>
4646

4747
<button
48+
type="button"
4849
ng-class="{ 'kuiButton--basic': !filter.active, 'kuiButton--primary': filter.active, 'hidden-xs': !showFields, 'hidden-sm': !showFields }"
4950
class="kuiButton kuiButton--small pull-right discover-field-filter-toggle"
5051
ng-click="showFilter = !showFilter"
51-
aria-label="Field Settings"
52+
aria-label="Show field settings"
5253
aria-haspopup="true"
5354
aria-expanded="{{showFilter}}"
5455
>

src/core_plugins/kibana/public/discover/components/field_chooser/lib/detail_views/string.html

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,22 @@ <h5 ng-show="!field.details.error">Quick Count <kbn-info info="Top 5 values base
2424
<div ng-if="!field.details.error">
2525
<div ng-repeat="bucket in ::field.details.buckets" class="discover-field-details-item">
2626
<div>
27+
<!-- Add/remove filter buttons -->
2728
<span ng-show="field.filterable" class="pull-right">
28-
<i aria-hidden="true" class="fa fa-search-minus pull-right discover-field-details-filter"
29-
ng-click="onAddFilter(field, bucket.value, '-')" data-test-subj="minus-{{::field.name}}-{{::bucket.display}}"></i>
30-
<i aria-hidden="true" class="fa fa-search-plus pull-right discover-field-details-filter"
31-
ng-click="onAddFilter(field, bucket.value, '+')" data-test-subj="plus-{{::field.name}}-{{::bucket.display}}"></i>
29+
<span aria-hidden="true" class="fa fa-search-minus pull-right discover-field-details-filter"
30+
ng-click="onAddFilter(field, bucket.value, '-')" data-test-subj="minus-{{::field.name}}-{{::bucket.display}}"></span>
31+
<span aria-hidden="true" class="fa fa-search-plus pull-right discover-field-details-filter"
32+
ng-click="onAddFilter(field, bucket.value, '+')" data-test-subj="plus-{{::field.name}}-{{::bucket.display}}"></span>
3233
</span>
33-
<div css-truncate css-truncate-expandable="true" class="discover-field-details-value" title="{{::bucket.display}}">
34-
{{::bucket.display}} <i ng-show="bucket.display === ''">Empty string</i>
34+
35+
<!-- Field value -->
36+
<div
37+
css-truncate
38+
css-truncate-expandable="true"
39+
class="discover-field-details-value"
40+
aria-label="Value: {{:: bucket.display === '' ? 'Empty string' : bucket.display }}"
41+
>
42+
{{::bucket.display}} <em ng-show="bucket.display === ''">Empty string</em>
3543
</div>
3644
</div>
3745
<kbn-tooltip text="{{::bucket.count}}" placement="right" append-to-body="1">

src/core_plugins/kibana/public/discover/index.html

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,11 +155,9 @@ <h2>Searching</h2>
155155
></doc-table>
156156

157157
<div ng-if="rows.length == opts.sampleSize" class="discover-table-footer">
158-
<center>
159-
These are the first {{opts.sampleSize}} documents matching
160-
your search, refine your search to see others.
161-
<a ng-click="toTop()" title="Back to top">Back to top.</a>
162-
</center>
158+
These are the first {{opts.sampleSize}} documents matching
159+
your search, refine your search to see others.
160+
<a ng-click="toTop()">Back to top.</a>
163161
</div>
164162
</div>
165163
</div>

src/core_plugins/kibana/public/discover/partials/no_results.html

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,18 @@ <h3>Shard Failures</h3>
1313
<ul>
1414
<li ng-repeat="failure in failures | limitTo: failuresShown"><strong>Index:</strong> {{failure.index}} <strong>Shard:</strong> {{failure.shard}} <strong>Reason:</strong> {{failure.reason}} </li>
1515
</ul>
16-
<a ng-click="showAllFailures()" ng-if="failures.length > failuresShown" title="Show More">Show More</a>
17-
<a ng-click="showLessFailures()" ng-if="failures.length === failuresShown && failures.length > 5" title="Show Less">Show Less</a>
16+
<a
17+
ng-click="showAllFailures()"
18+
ng-if="failures.length > failuresShown"
19+
>
20+
Show More
21+
</a>
22+
<a
23+
ng-click="showLessFailures()"
24+
ng-if="failures.length === failuresShown && failures.length > 5"
25+
>
26+
Show Less
27+
</a>
1828
</div>
1929

2030
<div ng-show="opts.timefield">

src/core_plugins/kibana/public/discover/styles/main.less

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@
9898
.discover-table-footer {
9999
background-color: @discover-table-footer-bg;
100100
padding: 5px 10px;
101+
text-align: center;
101102
}
102103

103104
.discover-table-details-toggle {
@@ -224,19 +225,19 @@
224225

225226
field-name,
226227
[field-name] {
227-
> i {
228+
&.no-results {
229+
color: @field-name-no-results-color;
230+
}
231+
}
232+
233+
.field-name-icon {
228234
margin-right: 5px;
229235
text-align: center;
230236
display: inline-block;
231237
width: 12px;
232238
color: @field-name-color;
233239
}
234240

235-
&.no-results {
236-
color: @field-name-no-results-color;
237-
}
238-
}
239-
240241
disc-field-chooser {
241242
.sidebar-item.active .sidebar-item-title {
242243
background-color: @sidebar-active-bg;

src/ui/public/directives/field_name.js

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
import $ from 'jquery';
22
import 'ui/filters/short_dots';
3+
import booleanFieldNameIcon from './field_name_icons/boolean_field_name_icon.html';
4+
import conflictFieldNameIcon from './field_name_icons/conflict_field_name_icon.html';
5+
import dateFieldNameIcon from './field_name_icons/date_field_name_icon.html';
6+
import geoPointFieldNameIcon from './field_name_icons/geo_point_field_name_icon.html';
7+
import ipFieldNameIcon from './field_name_icons/ip_field_name_icon.html';
8+
import murmur3FieldNameIcon from './field_name_icons/murmur3_field_name_icon.html';
9+
import numberFieldNameIcon from './field_name_icons/number_field_name_icon.html';
10+
import sourceFieldNameIcon from './field_name_icons/source_field_name_icon.html';
11+
import stringFieldNameIcon from './field_name_icons/string_field_name_icon.html';
12+
import unknownFieldNameIcon from './field_name_icons/unknown_field_name_icon.html';
13+
314
import { uiModules } from 'ui/modules';
415
const module = uiModules.get('kibana');
516

@@ -12,31 +23,25 @@ module.directive('fieldName', function ($compile, $rootScope, $filter) {
1223
'fieldType': '='
1324
},
1425
link: function ($scope, $el) {
26+
const typeToIconMap = {
27+
boolean: booleanFieldNameIcon,
28+
conflict: conflictFieldNameIcon,
29+
date: dateFieldNameIcon,
30+
geo_point: geoPointFieldNameIcon,
31+
ip: ipFieldNameIcon,
32+
murmur3: murmur3FieldNameIcon,
33+
number: numberFieldNameIcon,
34+
source: sourceFieldNameIcon,
35+
string: stringFieldNameIcon,
36+
};
1537

16-
const typeIcon = function (fieldType) {
17-
switch (fieldType) {
18-
case 'source':
19-
return '<i title="source" class="fa fa-file-text-o "></i>';
20-
case 'string':
21-
return '<i title="string"><strong>t</strong></i>';
22-
case 'murmur3':
23-
return '<i title="murmur3"><strong>h</strong></i>';
24-
case 'number':
25-
return '<i title="number"><strong>#</strong></i>';
26-
case 'date':
27-
return '<i title="date" class="fa fa-clock-o"></i>';
28-
case 'ip':
29-
return '<i title="ip" class="fa fa-laptop"></i>';
30-
case 'geo_point':
31-
return '<i title="geo_point" class="fa fa-globe"></i>';
32-
case 'boolean':
33-
return '<i title="boolean" class="fa fa-adjust"></i>';
34-
case 'conflict':
35-
return '<i title="conflict" class="fa fa-warning"></i>';
36-
default:
37-
return '<i title="unknown"><strong>?</strong></i>';
38+
function typeIcon(fieldType) {
39+
if (typeToIconMap.hasOwnProperty(fieldType)) {
40+
return typeToIconMap[fieldType];
3841
}
39-
};
42+
43+
return unknownFieldNameIcon;
44+
}
4045

4146
$rootScope.$watchMulti.call($scope, [
4247
'field',
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<span
2+
aria-label="Boolean field"
3+
class="field-name-icon kuiIcon fa-adjust"
4+
></span>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<span
2+
aria-label="Conflicting field"
3+
class="field-name-icon kuiIcon fa-warning"
4+
></span>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<span
2+
aria-label="Date field"
3+
class="field-name-icon kuiIcon fa-clock-o"
4+
></span>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<span
2+
aria-label="Geo-point field"
3+
class="field-name-icon kuiIcon fa-globe"
4+
></span>

0 commit comments

Comments
 (0)