fix: improve sortable table accessibility and column sort behavior#55730
Conversation
|
Thanks for your contributions @Nithin0620, Could you resend am empty commit message to retriger the netlify build and share a deploy preview link to a page that uses .sortable-table? Want to verify keyboard focus rings and screen-reader announcement |
✅ Pull request preview available for checkingBuilt without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
Triggered a fresh Netlify preview build. Sortable table deployment preview: This page uses |
|
Thanks, tested and was able to sort with space and enter key /lgtm nit: It will be to good to have a visible up and down arrows on the thead for sortable table (maybe raise am issue for discussion) |
|
LGTM label has been added. DetailsGit tree hash: 5de72337ea32bb171db88a27ca93a1152ceaba8b |
Thanks for the suggestion! Visible sort indicators would definitely improve discoverability for sortable columns. I’ll raise a follow-up issue for discussion and potential implementation separately to keep this PR focused on keyboard accessibility and sorting behavior fixes. |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: lmktfy The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Description
This PR improves
assets/js/sortable-table.jsfor.sortable-tablepages.Previously, sorting was click-only with no usable sort state for assistive technologies, and
data-sort-orderapplied globally to the table. After sorting one column descending, activating another column could continue in descending order instead of behaving like typical data tables (new column sorts ascending first).The update adds keyboard support (Enter and Space on headers), makes headers focusable, and refreshes
aria-sort(none, thenascending/descendingon the active column only). It tracksdata-sort-colso a different column always starts ascending; toggling applies when the same column is activated again.Sorting uses
textContentwith trimming instead ofinnerText, for more predictable collation. Thetbodyreference is reused when re-appending sorted rows.Changes made
data-sort-col+ conditional sort direction).aria-sorton headers (inactive columns set tonone).textContent.trim()overinnerTextfor stable string comparisons.tbodywhen moving rows.