Skip to content

Commit

Permalink
079d776d2c7eaf9f0131b195d41da7afccc8e3dd Fix: tabindex for keyboard…
Browse files Browse the repository at this point in the history
… 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
  • Loading branch information
dtbuild committed Oct 23, 2024
1 parent fb3d849 commit 8919324
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 25 deletions.
2 changes: 1 addition & 1 deletion datatables.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
],
"src-repo": "http://github.com/DataTables/Responsive",
"last-tag": "3.0.3",
"last-sync": "f0d38e6f1e3405f2e626eec16263186c79855aa3"
"last-sync": "079d776d2c7eaf9f0131b195d41da7afccc8e3dd"
}
25 changes: 14 additions & 11 deletions js/dataTables.responsive.js
Original file line number Diff line number Diff line change
Expand Up @@ -743,11 +743,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 @@ -814,12 +818,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 @@ -1370,7 +1368,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
2 changes: 1 addition & 1 deletion js/dataTables.responsive.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/dataTables.responsive.min.mjs

Large diffs are not rendered by default.

25 changes: 14 additions & 11 deletions js/dataTables.responsive.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -703,11 +703,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 @@ -774,12 +778,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 @@ -1330,7 +1328,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 8919324

Please sign in to comment.