Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Makes filter keep focus when hiding/showing sticky #1711

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions js/widgets/widget-stickyHeaders.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi! Thanks for contributing and I'm sorry for taking so long to follow up on this PR!

Would you please change this to get the cell's index from the data-column attribute since the header may have a colspan which would mess up this calculation.

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();
Expand Down