Bug 38827: DataTables - Do not filter when inputs lose focus

On a table using DataTables and the REST API wrapper with the column
filters, if one input is used to filter the table the query will be made
twice: when the user stopped typing and when the input will lose the
focus.

Test plan:
Search for patron
Open the dev console, "Network" tab
In the "Card" column filter enter "0000"
Notice that the table is filtered and that a request has been made
Click outside of the "Card" input
=> Without this patch another request (the same) is made and the table
updated
=> With this patch applied no request is made when the input loses the
focus.

Signed-off-by: Jake Deery <jake.deery@ptfs-europe.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Jonathan Druart 2025-01-06 10:48:24 +01:00 committed by Katrin Fischer
parent 368d59c9a9
commit e32533ef22
No known key found for this signature in database
GPG Key ID: 0EF6E2C03357A834
1 changed files with 2 additions and 1 deletions

View File

@ -877,7 +877,8 @@ function _dt_add_delay_filters(table_dt, table_node) {
var i = table_dt.column.index('fromVisible', visible_i);
$(this).find("input")
.unbind()
.bind("keyup change", function(){
.bind("keyup change", function(e){
if (e.keyCode === undefined) return;
col_input_search(i, this.value)
});