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

No search on enter if filters are unchanged #1631 #1642

Merged
merged 4 commits into from
Dec 1, 2019
Merged
Show file tree
Hide file tree
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
16 changes: 9 additions & 7 deletions js/jquery.tablesorter.widgets.js
Original file line number Diff line number Diff line change
Expand Up @@ -1288,7 +1288,7 @@
event.preventDefault();
// init search with no delay
$( this ).attr( 'data-lastSearchTime', new Date().getTime() );
tsf.searching( table, eventType !== 'keypress', true, column );
tsf.searching( table, eventType !== 'keypress' || event.which === tskeyCodes.enter, true, column );
}
});
},
Expand Down Expand Up @@ -1363,12 +1363,14 @@
}
// return if the last search is the same; but filter === false when updating the search
// see example-widget-filter.html filter toggle buttons
if ( tsf.equalFilters(c, c.lastSearch, currentFilters) && filter !== false ) {
return;
} else if ( filter === false ) {
// force filter refresh
c.lastCombinedFilter = '';
c.lastSearch = [];
if ( tsf.equalFilters(c, c.lastSearch, currentFilters) ) {
if ( filter !== false ) {
return;
} else {
// force filter refresh
c.lastCombinedFilter = '';
c.lastSearch = [];
}
}
// define filter inside it is false
filters = filters || [];
Expand Down
16 changes: 9 additions & 7 deletions js/widgets/widget-filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -887,7 +887,7 @@
event.preventDefault();
// init search with no delay
$( this ).attr( 'data-lastSearchTime', new Date().getTime() );
tsf.searching( table, eventType !== 'keypress', true, column );
tsf.searching( table, eventType !== 'keypress' || event.which === tskeyCodes.enter, true, column );
}
});
},
Expand Down Expand Up @@ -962,12 +962,14 @@
}
// return if the last search is the same; but filter === false when updating the search
// see example-widget-filter.html filter toggle buttons
if ( tsf.equalFilters(c, c.lastSearch, currentFilters) && filter !== false ) {
return;
} else if ( filter === false ) {
// force filter refresh
c.lastCombinedFilter = '';
c.lastSearch = [];
if ( tsf.equalFilters(c, c.lastSearch, currentFilters) ) {
if ( filter !== false ) {
return;
} else {
// force filter refresh
c.lastCombinedFilter = '';
c.lastSearch = [];
}
}
// define filter inside it is false
filters = filters || [];
Expand Down