Skip to content

fix: improve sortable table accessibility and column sort behavior#55730

Merged
k8s-ci-robot merged 2 commits into
kubernetes:mainfrom
Nithin0620:fix/sortable-table-accessibility-and-performance
May 14, 2026
Merged

fix: improve sortable table accessibility and column sort behavior#55730
k8s-ci-robot merged 2 commits into
kubernetes:mainfrom
Nithin0620:fix/sortable-table-accessibility-and-performance

Conversation

@Nithin0620
Copy link
Copy Markdown
Contributor

Description

This PR improves assets/js/sortable-table.js for .sortable-table pages.

Previously, sorting was click-only with no usable sort state for assistive technologies, and data-sort-order applied 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, then ascending / descending on the active column only). It tracks data-sort-col so a different column always starts ascending; toggling applies when the same column is activated again.

Sorting uses textContent with trimming instead of innerText, for more predictable collation. The tbody reference is reused when re-appending sorted rows.

Changes made

  • Fixed multi-column UX by resetting to ascending when the sorted column changes (data-sort-col + conditional sort direction).
  • Improved accessibility: focusable headers, Enter / Space, and aria-sort on headers (inactive columns set to none).
  • Prefer textContent.trim() over innerText for stable string comparisons.
  • Small DOM clarity: reuse a single tbody when moving rows.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label May 9, 2026
@k8s-ci-robot k8s-ci-robot requested review from lmktfy and tengqm May 9, 2026 19:41
@k8s-ci-robot k8s-ci-robot added area/web-development Issues or PRs related to the kubernetes.io's infrastructure, design, or build processes sig/docs Categorizes an issue or PR as relevant to SIG Docs. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels May 9, 2026
@Caesarsage
Copy link
Copy Markdown
Contributor

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

@netlify
Copy link
Copy Markdown

netlify Bot commented May 12, 2026

Pull request preview available for checking

Built without sensitive environment variables

Name Link
🔨 Latest commit 13e507e
🔍 Latest deploy log https://app.netlify.com/projects/kubernetes-io-main-staging/deploys/6a032756ed102a00089c0c3a
😎 Deploy Preview https://deploy-preview-55730--kubernetes-io-main-staging.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@Nithin0620
Copy link
Copy Markdown
Contributor Author

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

Triggered a fresh Netlify preview build.

Sortable table deployment preview:
https://deploy-preview-55730--kubernetes-io-main-staging.netlify.app/docs/reference/command-line-tools-reference/feature-gates/#feature-gates-for-alpha-or-beta-features

This page uses .sortable-table, including keyboard sorting support and updated aria-sort behavior introduced in this PR.

@Caesarsage
Copy link
Copy Markdown
Contributor

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)

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 14, 2026
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

LGTM label has been added.

DetailsGit tree hash: 5de72337ea32bb171db88a27ca93a1152ceaba8b

@Nithin0620
Copy link
Copy Markdown
Contributor Author

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)

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.

Copy link
Copy Markdown
Member

@lmktfy lmktfy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

/approve

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[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

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 14, 2026
@k8s-ci-robot k8s-ci-robot merged commit 1c7adbc into kubernetes:main May 14, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. area/web-development Issues or PRs related to the kubernetes.io's infrastructure, design, or build processes cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. sig/docs Categorizes an issue or PR as relevant to SIG Docs. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants