Skip to content

Commit

Permalink
Fix: tabindex for keyboard accessability wasn't being applied corre…
Browse files Browse the repository at this point in the history
…ctly

Fix: `tabindex` could incorrectly be applied to the final column when Ajax loading data

#135
  • Loading branch information
AllanJard committed Oct 23, 2024
1 parent f0d38e6 commit 079d776
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions js/dataTables.responsive.js
Original file line number Diff line number Diff line change
Expand Up @@ -696,11 +696,15 @@ $.extend(Responsive.prototype, {
.filter('.dtr-control')
.removeClass('dtr-control');

dt.cells(null, firstVisible, { page: 'current' })
.nodes()
.to$()
.addClass('dtr-control');
if (firstVisible >= 0) {
dt.cells(null, firstVisible, { page: 'current' })
.nodes()
.to$()
.addClass('dtr-control');
}
}

this._tabIndexes();
},

/**
Expand Down Expand Up @@ -767,12 +771,6 @@ $.extend(Responsive.prototype, {
details.target = 'td.dtr-control, th.dtr-control';
}

// Keyboard accessibility
dt.on('draw.dtr', function () {
that._tabIndexes();
});
that._tabIndexes(); // Initial draw has already happened

$(dt.table().body()).on('keyup.dtr', 'td, th', function (e) {
if (e.keyCode === 13 && $(this).data('dtr-keyboard')) {
$(this).click();
Expand Down Expand Up @@ -1323,7 +1321,12 @@ $.extend(Responsive.prototype, {
target = '>td:first-child, >th:first-child';
}

$(target, dt.rows({ page: 'current' }).nodes())
var rows = dt.rows({ page: 'current' }).nodes();
var nodes = target === 'tr'
? $(rows)
: $(target, rows);

nodes
.attr('tabIndex', ctx.iTabIndex)
.data('dtr-keyboard', 1);
}
Expand Down

0 comments on commit 079d776

Please sign in to comment.