Bug 38827

Summary: New search performed when column filters lose focus
Product: Koha Reporter: Jonathan Druart <jonathan.druart>
Component: Staff interfaceAssignee: Jonathan Druart <jonathan.druart>
Status: Pushed to stable --- QA Contact: Martin Renvoize (ashimema) <martin.renvoize>
Severity: normal    
Priority: P5 - low CC: david, gmcharlt, jake.deery, martin.renvoize
Version: unspecified   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=38116
GIT URL: Change sponsored?: ---
Patch complexity: --- Documentation contact:
Documentation submission: Text to go in the release notes:
This fixes DataTable tables to stop duplicate update queries being made when values are entered for filters and then the focus is lost (for example, clicking somewhere else on the screen).
Version(s) released in:
25.05.00,24.11.04
Circulation function:
Attachments: Bug 38827: DataTables - Do not filter when inputs lose focus
Bug 38827: DataTables - Do not filter when inputs lose focus
Bug 38827: DataTables - Do not filter when inputs lose focus

Description Jonathan Druart 2025-01-06 09:46:54 UTC
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.
Comment 1 Jonathan Druart 2025-01-06 09:52:49 UTC
Created attachment 176147 [details] [review]
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.
Comment 2 Jake Deery 2025-01-06 16:08:58 UTC
Created attachment 176162 [details] [review]
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>
Comment 3 Jake Deery 2025-01-06 16:09:22 UTC
Worked for me, nice optimisation.

Jake.
Comment 4 Martin Renvoize (ashimema) 2025-01-07 15:35:52 UTC
Created attachment 176197 [details] [review]
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>
Comment 5 Katrin Fischer 2025-01-10 17:00:43 UTC
Pushed for 25.05!

Well done everyone, thank you!
Comment 6 Paul Derscheid 2025-04-17 12:45:42 UTC
Nice work everyone!

Pushed to 24.11.x for 24.11.04