From 22335d67a0afe6904642c29b5b80d6e0085d4aa4 Mon Sep 17 00:00:00 2001 From: samgrrehder Date: Tue, 11 Feb 2020 15:42:07 -0300 Subject: [PATCH] Makes filter keep focus when hiding/showing sticky The filter doesn't change the focused element when showing or hiding the sticky header. This fixes it. --- js/widgets/widget-stickyHeaders.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/js/widgets/widget-stickyHeaders.js b/js/widgets/widget-stickyHeaders.js index 32018efd..097070cd 100644 --- a/js/widgets/widget-stickyHeaders.js +++ b/js/widgets/widget-stickyHeaders.js @@ -206,6 +206,18 @@ .addClass( state ) .css(cssSettings); } + if (isVisible !== laststate) { + // make sure the focused filter stay focused after showing/hiding sticky + var $td = $(document.activeElement).closest('td'), + column = $td.parent().children().index($td); + if (column >= 0 && c.$filters) { + if (isVisible === "hidden") { + c.$filters.eq(column).find('a, select, input').focus(); + } else { + $stickyTable.find('a, select, input').eq(column).focus(); + } + } + } if (isVisible !== laststate || resizing) { // make sure the column widths match resizeHeader();