()
| 16560 | |
| 16561 | // Add click handler |
| 16562 | header.addEventListener('click', async () => { |
| 16563 | const sortSelect = document.getElementById('sort-select'); |
| 16564 | if (!sortSelect) return; |
| 16565 | |
| 16566 | const currentSort = sortSelect.value; |
| 16567 | let newSort; |
| 16568 | |
| 16569 | // Determine new sort based on current state |
| 16570 | if (currentSort === `${sortKey}-asc`) { |
| 16571 | newSort = `${sortKey}-desc`; |
| 16572 | } else if (currentSort === `${sortKey}-desc`) { |
| 16573 | newSort = `${sortKey}-asc`; |
| 16574 | } else { |
| 16575 | // Default to ascending when clicking a new column |
| 16576 | newSort = `${sortKey}-asc`; |
| 16577 | } |
| 16578 | |
| 16579 | // Update sort select - check if option exists first |
| 16580 | if (sortSelect.querySelector(`option[value="${newSort}"]`)) { |
| 16581 | sortSelect.value = newSort; |
no test coverage detected