From 6135266b2b2ad0bda74e510d78cf0e49c4623054 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 7 Nov 2024 14:16:44 +0100 Subject: [PATCH] Bug 38391: Redraw the filters row on table redraw We used to adjust the filters row when the column visibility changed. It was working, but at the initialization of the table this event if fired once per columns. On the items table it means 36x. When a filtering/sorting, the draw event is triggered once, but the column-visibility.dt is called 36x Test plan: Try with and without this patch and compare the delay between the query is received and the page is redrawn. You can test with 1000 libraries on the items table. "Show filters" then filters using the global search. On Firefox you will notice that the response is received but the table not redrawn directly. With this patch it should be redrawn pretty fase. Another test would be to add the following 2 lines: + let i = 0; table_dt.on("draw", function(){ + console.log("redraw filters %s".format(i)); if ( add_filters ) { _dt_add_filters(this, table_dt, filters_options); } Open the console and notice that "redraw filters" is logged only once. Signed-off-by: Lucas Gass --- koha-tmpl/intranet-tmpl/prog/js/datatables.js | 2 +- koha-tmpl/intranet-tmpl/prog/js/vue/components/KohaTable.vue | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/js/datatables.js b/koha-tmpl/intranet-tmpl/prog/js/datatables.js index 1a0a893c5ab..82c3cd4fbee 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/datatables.js +++ b/koha-tmpl/intranet-tmpl/prog/js/datatables.js @@ -1143,7 +1143,7 @@ function _dt_save_restore_state(table_settings, external_filter_nodes={}){ _dt_add_filters(this, table_dt, filters_options); } - table_dt.on("column-visibility.dt", function(){ + table_dt.on("draw", function(){ if ( add_filters ) { _dt_add_filters(this, table_dt, filters_options); } diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/KohaTable.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/KohaTable.vue index d56b9563c85..1e9f33c89be 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/KohaTable.vue +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/KohaTable.vue @@ -224,7 +224,7 @@ export default { _dt_add_filters(table_node, dt, filters_options) } - dt.on("column-visibility.dt", function () { + dt.on("draw", function () { if (add_filters) { _dt_add_filters(table_node, dt, filters_options) } -- 2.39.2