From 299c9e37f9ca2f73b4822f43c398a8fa1a9b7196 Mon Sep 17 00:00:00 2001 From: Allan Jardine Date: Thu, 18 Jun 2020 08:35:44 +0000 Subject: [PATCH 1/2] Fix: "Last" paging button would be active on an empty table DD-1525 --- js/ext/ext.paging.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/ext/ext.paging.js b/js/ext/ext.paging.js index 085eebd6a..4b1c7877e 100644 --- a/js/ext/ext.paging.js +++ b/js/ext/ext.paging.js @@ -131,7 +131,7 @@ $.extend( true, DataTable.ext.renderer, { case 'last': btnDisplay = lang.sLast; - if ( page === pages-1 ) { + if ( pages === 0 || page === pages-1 ) { tabIndex = -1; btnClass += ' ' + disabledClass; } From 572252f9ec66cd08759a0cd10a6b3800fa5a644e Mon Sep 17 00:00:00 2001 From: Colin Marks Date: Thu, 18 Jun 2020 13:01:10 +0100 Subject: [PATCH 2/2] DEV added test for the disabled paging control elements (DD-1525) --- test/options/Options/pagingType.js | 56 ++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/test/options/Options/pagingType.js b/test/options/Options/pagingType.js index d96148523..f57a1ed74 100644 --- a/test/options/Options/pagingType.js +++ b/test/options/Options/pagingType.js @@ -217,6 +217,62 @@ describe('pageType Option', function() { }); }); + describe('Check the various paging types when empty table', function() { + dt.html('empty'); + it('Default', function() { + $('#example').dataTable(); + expect($('.paginate_button').length).toBe(2); + }); + + dt.html('empty'); + it('Numbers', function() { + $('#example').dataTable({ + pagingType: 'numbers' + }); + expect($('.paginate_button').length).toBe(0); + }); + + dt.html('empty'); + it('Simple', function() { + $('#example').dataTable({ + pagingType: 'simple' + }); + expect($('.paginate_button').length).toBe(2); + }); + + dt.html('empty'); + it('Simple Numbers', function() { + $('#example').dataTable({ + pagingType: 'simple_numbers' + }); + expect($('.paginate_button').length).toBe(2); + }); + + dt.html('empty'); + it('Full', function() { + $('#example').dataTable({ + pagingType: 'full' + }); + expect($('.paginate_button').length).toBe(4); + }); + + dt.html('empty'); + it('Full Numbers', function() { + $('#example').dataTable({ + pagingType: 'full_numbers' + }); + expect($('.paginate_button').length).toBe(4); + }); + + dt.html('empty'); + it('First Last Numbers', function() { + $('#example').dataTable({ + pagingType: 'first_last_numbers' + }); + expect($('.paginate_button').length).toBe(2); + }); + }); + describe('General odds and ends', function() { dt.html('basic'); it('Short page length when mid-table', function() {