From 6f0b278bd9d435e398d6e1eaae308d9642988bb9 Mon Sep 17 00:00:00 2001 From: mARTin-B78 Date: Mon, 22 Jun 2026 15:07:55 +0200 Subject: [PATCH] fix: Resolve table header click-to-sort logic --- static/js/voice-library.js | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/static/js/voice-library.js b/static/js/voice-library.js index f2a09e1..07142a3 100644 --- a/static/js/voice-library.js +++ b/static/js/voice-library.js @@ -107,7 +107,7 @@ function toggleSortDir() { } function syncSortHeaders() { - document.querySelectorAll('.vl-header [data-sort]').forEach(el => { + document.querySelectorAll('.vl-header [data-sort], .vl-table-header [data-sort]').forEach(el => { el.classList.remove('sort-asc', 'sort-desc'); if (el.dataset.sort === _sortField) el.classList.add(_sortDir === 1 ? 'sort-asc' : 'sort-desc'); @@ -159,14 +159,8 @@ document.addEventListener('click', e => { const field = th.dataset.sort; if (field) { const sel = document.getElementById('voice-sort-field'); - if (sel && sel.value === field) { - window._voiceSortDir *= -1; // toggle dir - } else if (sel) { - sel.value = field; - window._voiceSortDir = 1; // default to desc for new field (or asc if you want) - } - readLibrarySortConfig(); - renderVoiceList(); + if (sel) sel.value = field; + setSort(field); } } });