From d7ed2225b495f59afa7bd9f32b3936bd8e978068 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Mon, 16 Feb 2026 15:09:55 +0100 Subject: [PATCH] Ensure that part tables are correctly sorted on initial load --- .../elements/datatables/datatables_controller.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/assets/controllers/elements/datatables/datatables_controller.js b/assets/controllers/elements/datatables/datatables_controller.js index 5a50623d..9ac23483 100644 --- a/assets/controllers/elements/datatables/datatables_controller.js +++ b/assets/controllers/elements/datatables/datatables_controller.js @@ -108,11 +108,19 @@ export default class extends Controller { const raw_order = saved_state.order; settings.initial_order = raw_order.map((order) => { + //Skip if direction is empty, as this is the default, otherwise datatables server is confused when the order is sent in the request, but the initial order is set to an empty direction + if (order[1] === '') { + return null; + } + return { column: order[0], dir: order[1] } }); + + //Remove null values from the initial_order array + settings.initial_order = settings.initial_order.filter(order => order !== null); } let options = {