Skip to content

Commit 079d776

Browse files
committed
Fix: tabindex for keyboard accessability wasn't being applied correctly
Fix: `tabindex` could incorrectly be applied to the final column when Ajax loading data #135
1 parent f0d38e6 commit 079d776

1 file changed

Lines changed: 14 additions & 11 deletions

File tree

js/dataTables.responsive.js

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

699-
dt.cells(null, firstVisible, { page: 'current' })
700-
.nodes()
701-
.to$()
702-
.addClass('dtr-control');
699+
if (firstVisible >= 0) {
700+
dt.cells(null, firstVisible, { page: 'current' })
701+
.nodes()
702+
.to$()
703+
.addClass('dtr-control');
704+
}
703705
}
706+
707+
this._tabIndexes();
704708
},
705709

706710
/**
@@ -767,12 +771,6 @@ $.extend(Responsive.prototype, {
767771
details.target = 'td.dtr-control, th.dtr-control';
768772
}
769773

770-
// Keyboard accessibility
771-
dt.on('draw.dtr', function () {
772-
that._tabIndexes();
773-
});
774-
that._tabIndexes(); // Initial draw has already happened
775-
776774
$(dt.table().body()).on('keyup.dtr', 'td, th', function (e) {
777775
if (e.keyCode === 13 && $(this).data('dtr-keyboard')) {
778776
$(this).click();
@@ -1323,7 +1321,12 @@ $.extend(Responsive.prototype, {
13231321
target = '>td:first-child, >th:first-child';
13241322
}
13251323

1326-
$(target, dt.rows({ page: 'current' }).nodes())
1324+
var rows = dt.rows({ page: 'current' }).nodes();
1325+
var nodes = target === 'tr'
1326+
? $(rows)
1327+
: $(target, rows);
1328+
1329+
nodes
13271330
.attr('tabIndex', ctx.iTabIndex)
13281331
.data('dtr-keyboard', 1);
13291332
}

0 commit comments

Comments
 (0)