Skip to content

Commit 8919324

Browse files
author
dtbuild
committed
079d776d2c7eaf9f0131b195d41da7afccc8e3dd Fix: tabindex for keyboard accessability wasn't being applied correctly
Fix: `tabindex` could incorrectly be applied to the final column when Ajax loading data DataTables/Responsive#135 Sync to source repo @079d776d2c7eaf9f0131b195d41da7afccc8e3dd
1 parent fb3d849 commit 8919324

5 files changed

Lines changed: 31 additions & 25 deletions

File tree

datatables.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@
1111
],
1212
"src-repo": "http://github.com/DataTables/Responsive",
1313
"last-tag": "3.0.3",
14-
"last-sync": "f0d38e6f1e3405f2e626eec16263186c79855aa3"
14+
"last-sync": "079d776d2c7eaf9f0131b195d41da7afccc8e3dd"
1515
}

js/dataTables.responsive.js

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -743,11 +743,15 @@ $.extend(Responsive.prototype, {
743743
.filter('.dtr-control')
744744
.removeClass('dtr-control');
745745

746-
dt.cells(null, firstVisible, { page: 'current' })
747-
.nodes()
748-
.to$()
749-
.addClass('dtr-control');
746+
if (firstVisible >= 0) {
747+
dt.cells(null, firstVisible, { page: 'current' })
748+
.nodes()
749+
.to$()
750+
.addClass('dtr-control');
751+
}
750752
}
753+
754+
this._tabIndexes();
751755
},
752756

753757
/**
@@ -814,12 +818,6 @@ $.extend(Responsive.prototype, {
814818
details.target = 'td.dtr-control, th.dtr-control';
815819
}
816820

817-
// Keyboard accessibility
818-
dt.on('draw.dtr', function () {
819-
that._tabIndexes();
820-
});
821-
that._tabIndexes(); // Initial draw has already happened
822-
823821
$(dt.table().body()).on('keyup.dtr', 'td, th', function (e) {
824822
if (e.keyCode === 13 && $(this).data('dtr-keyboard')) {
825823
$(this).click();
@@ -1370,7 +1368,12 @@ $.extend(Responsive.prototype, {
13701368
target = '>td:first-child, >th:first-child';
13711369
}
13721370

1373-
$(target, dt.rows({ page: 'current' }).nodes())
1371+
var rows = dt.rows({ page: 'current' }).nodes();
1372+
var nodes = target === 'tr'
1373+
? $(rows)
1374+
: $(target, rows);
1375+
1376+
nodes
13741377
.attr('tabIndex', ctx.iTabIndex)
13751378
.data('dtr-keyboard', 1);
13761379
}

js/dataTables.responsive.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/dataTables.responsive.min.mjs

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

js/dataTables.responsive.mjs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -703,11 +703,15 @@ $.extend(Responsive.prototype, {
703703
.filter('.dtr-control')
704704
.removeClass('dtr-control');
705705

706-
dt.cells(null, firstVisible, { page: 'current' })
707-
.nodes()
708-
.to$()
709-
.addClass('dtr-control');
706+
if (firstVisible >= 0) {
707+
dt.cells(null, firstVisible, { page: 'current' })
708+
.nodes()
709+
.to$()
710+
.addClass('dtr-control');
711+
}
710712
}
713+
714+
this._tabIndexes();
711715
},
712716

713717
/**
@@ -774,12 +778,6 @@ $.extend(Responsive.prototype, {
774778
details.target = 'td.dtr-control, th.dtr-control';
775779
}
776780

777-
// Keyboard accessibility
778-
dt.on('draw.dtr', function () {
779-
that._tabIndexes();
780-
});
781-
that._tabIndexes(); // Initial draw has already happened
782-
783781
$(dt.table().body()).on('keyup.dtr', 'td, th', function (e) {
784782
if (e.keyCode === 13 && $(this).data('dtr-keyboard')) {
785783
$(this).click();
@@ -1330,7 +1328,12 @@ $.extend(Responsive.prototype, {
13301328
target = '>td:first-child, >th:first-child';
13311329
}
13321330

1333-
$(target, dt.rows({ page: 'current' }).nodes())
1331+
var rows = dt.rows({ page: 'current' }).nodes();
1332+
var nodes = target === 'tr'
1333+
? $(rows)
1334+
: $(target, rows);
1335+
1336+
nodes
13341337
.attr('tabIndex', ctx.iTabIndex)
13351338
.data('dtr-keyboard', 1);
13361339
}

0 commit comments

Comments
 (0)