Skip to content

Commit af2914a

Browse files
committed
🐛 Fix DataTable sorting breaking with special chars in headings
1 parent 02b99de commit af2914a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/components/DataTable/DataTable.astro

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -251,9 +251,9 @@ const hasPagination = data?.length && itemsPerPage
251251
const sortedTableRows = Array.from(
252252
table?.querySelectorAll('tbody tr') as NodeListOf<HTMLTableRowElement>
253253
).sort((a, b) => {
254-
let aValue: string | number = (a.querySelector(`[data-name=${sortBy}]`) as HTMLElement)
254+
let aValue: string | number = (a.querySelector(`[data-name="${sortBy}"]`) as HTMLElement)
255255
?.innerText.replace(/\s/g, '')
256-
let bValue: string | number = (b.querySelector(`[data-name=${sortBy}]`) as HTMLElement)
256+
let bValue: string | number = (b.querySelector(`[data-name="${sortBy}"]`) as HTMLElement)
257257
?.innerText.replace(/\s/g, '')
258258

259259
if (!isNaN(aValue as any)) {
@@ -298,7 +298,7 @@ const hasPagination = data?.length && itemsPerPage
298298
return
299299
}
300300

301-
const affectedTableCells = Array.from(table.querySelectorAll(`[data-name=${eventName}]`)) as HTMLElement[]
301+
const affectedTableCells = Array.from(table.querySelectorAll(`[data-name="${eventName}"]`)) as HTMLElement[]
302302

303303
const columnToggleListElement = Array.from(event.list.children)
304304
.find(child => (child as HTMLLIElement).dataset.name === event.name) as HTMLLIElement

0 commit comments

Comments
 (0)