Skip to content

Commit

Permalink
[Accessibility] Avoid empty th in doc-table header row (#12364)
Browse files Browse the repository at this point in the history
  • Loading branch information
weltenwort authored Jun 21, 2017
1 parent 57f7da6 commit 1eaf83e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
20 changes: 10 additions & 10 deletions src/ui/public/doc_table/__tests__/lib/rows_headers.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ describe('Doc Table', function () {

it('should create a time column if the timefield is defined', function () {
const childElems = parentElem.find(elemType);
expect(childElems.length).to.be(2);
expect(childElems.length).to.be(1);
});

it('should be able to add and remove columns', function () {
Expand All @@ -61,28 +61,28 @@ describe('Doc Table', function () {
$parentScope.columns = ['bytes'];
parentElem.scope().$digest();
childElems = parentElem.find(elemType);
expect(childElems.length).to.be(3);
expect($(childElems[2]).text()).to.contain('bytes');
expect(childElems.length).to.be(2);
expect($(childElems[1]).text()).to.contain('bytes');

$parentScope.columns = ['bytes', 'request_body'];
parentElem.scope().$digest();
childElems = parentElem.find(elemType);
expect(childElems.length).to.be(4);
expect($(childElems[3]).text()).to.contain('request_body');
expect(childElems.length).to.be(3);
expect($(childElems[2]).text()).to.contain('request_body');

$parentScope.columns = ['request_body'];
parentElem.scope().$digest();
childElems = parentElem.find(elemType);
expect(childElems.length).to.be(3);
expect($(childElems[2]).text()).to.contain('request_body');
expect(childElems.length).to.be(2);
expect($(childElems[1]).text()).to.contain('request_body');
});

it('should create only the toggle column if there is no timeField', function () {
delete parentElem.scope().indexPattern.timeFieldName;
parentElem.scope().$digest();

const childElems = parentElem.find(elemType);
expect(childElems.length).to.be(1);
expect(childElems.length).to.be(0);
});

};
Expand Down Expand Up @@ -117,7 +117,7 @@ describe('Doc Table', function () {
});

describe('adding and removing columns', function () {
columnTests('th', $elem);
columnTests('[data-test-subj~="docTableHeaderField"]', $elem);
});

describe('cycleSortOrder function', function () {
Expand Down Expand Up @@ -252,7 +252,7 @@ describe('Doc Table', function () {
});

describe('adding and removing columns', function () {
columnTests('td', $elem);
columnTests('[data-test-subj~="docTableField"]', $elem);
});

describe('details row', function () {
Expand Down
14 changes: 11 additions & 3 deletions src/ui/public/doc_table/components/table_header.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<tr>
<th width="1%"></th>
<th ng-if="indexPattern.timeFieldName" data-test-subj="docTableHeaderField">
<td width="1%"></td>
<th
ng-if="indexPattern.timeFieldName"
data-test-subj="docTableHeaderField"
scope="col"
>
<span>Time <button
id="docTableHeaderFieldSort{{indexPattern.timeFieldName}}"
tabindex="0"
Expand All @@ -13,7 +17,11 @@
></button>
</span>
</th>
<th ng-repeat="name in columns" data-test-subj="docTableHeaderField">
<th
ng-repeat="name in columns"
data-test-subj="docTableHeaderField"
scope="col"
>
<span class="table-header-name">
{{name | shortDots}}
<button
Expand Down

0 comments on commit 1eaf83e

Please sign in to comment.