Skip to content

Commit aa3149d

Browse files
committed
fix date sorting
1 parent a9f0216 commit aa3149d

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# CHANGELOG.md
22

3+
## 0.33.1 (unreleased)
4+
5+
- Fix a bug where the table component would not format numbers if sorting was not enabled.
6+
- Fix a bug with date sorting in the table component.
7+
8+
39
## 0.33.0 (2025-02-15)
410

511
### 1. Routing & URL Enhancements 🔀

sqlpage/sqlpage.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,16 @@ function apply_number_formatting(table_el) {
100100
* @param {HTMLElement[]} sort_buttons
101101
*/
102102
function table_parse_data(table_el, sort_buttons) {
103+
const is_num = [...sort_buttons].map(
104+
(btn_el) => btn_el.parentElement.dataset.column_type === "number",
105+
);
103106
return [...table_el.querySelectorAll("tbody tr")].map((tr_el) => {
104107
const cells = tr_el.getElementsByTagName("td");
105108
return {
106109
el: tr_el,
107110
sort_keys: sort_buttons.map((btn_el, idx) => {
108111
const str = cells[idx]?.textContent;
109-
const num = Number.parseFloat(str);
112+
const num = is_num[idx] ? Number.parseFloat(str) : Number.NaN;
110113
return { num, str };
111114
}),
112115
};

0 commit comments

Comments
 (0)