Skip to content

fix(ui-table): don't append a sort state to unsorted v1 captions - #2671

Open
balzss wants to merge 1 commit into
masterfrom
fix/ui-table-unsorted-caption-v1
Open

fix(ui-table): don't append a sort state to unsorted v1 captions#2671
balzss wants to merge 1 commit into
masterfrom
fix/ui-table-unsorted-caption-v1

Conversation

@balzss

@balzss balzss commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Summary

An unsorted v1 Table with a plain string caption renders Sorted by undefined (undefined) into both its <caption> and its accessible name:

aria-label="Movies Sorted by undefined (undefined)"

getCaptionText lost its if (!sortInfo) return caption guard in aac2b17 (#2574), which restructured it around the new TableCaption function form. Shipped in v11.7.4. v2 is unaffected — caption must be a function there.

Our own docs site is affected too: the __docs__ Properties, Params, Returns and ComponentTheme tables all use v1 with string captions.

Changes

  • Restore the early return in Table/v1/index.tsx. The function-caption branch is untouched, and the as string cast matches SECURITY.3 — the value feeds aria-label, which needs a string.
  • Add Table/v1/__tests__/Table.test.tsx. v1 had no test coverage at all, which is why this shipped: the existing suite imports /latest (v2), and fix(ui-table): fix caption for table to be responsive to sorting #2574 converted its last string captions to functions.

Test Plan

  • The two unsorted tests fail on unpatched source and pass with the fix. The sorted test passes either way, guarding against over-correcting.
  • pnpm run test:vitest ui-table — 25 passed. Full unit suite — 2218 passed. build:types clean.
  • Docs app: Properties and Component-theme captions render clean with matching aria-labels, and the function-caption sort form still works.

Worth knowing for future tests: the new file imports relatively on purpose. getWorkspaceAliases() in vitest.config.mts is only wired into the browser project, so a @instructure/ui-table/* import in the web project resolves to built es/ output rather than source.

Fixes INSTUI-5138

Reported by @drakeaharper in #instui while upgrading canvas-lms onto public 11.7.4, where it broke 10 vitest files and 6 Selenium specs. Supersedes #2666.

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://instructure.design/pr-preview/pr-2671/

Built to branch gh-pages at 2026-08-13 12:27 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@github-actions

Copy link
Copy Markdown
Contributor

Visual regression report

⚠️ Changes detected.

Status Count
Unchanged 0
Changed 1
New 96
Removed 32

📊 View full report

Diff images (33)

alert.png — baseline no longer produced

avatar.png — baseline no longer produced

badge.png — baseline no longer produced

billboard.png — baseline no longer produced

breadcrumb.png — baseline no longer produced

button-and-derivatives.png — baseline no longer produced

byline.png — baseline no longer produced

calendar.png — baseline no longer produced

checkbox.png — baseline no longer produced

checkboxgroup.png — baseline no longer produced

colorpicker.png — baseline no longer produced

contextview.png — baseline no longer produced

custom-and-lucide-icons.png — baseline no longer produced

dateinput-dateinput2.png — baseline no longer produced

datetimeinput.png — baseline no longer produced

diff-demo.png — 6324 pixels differ

drilldown.png — baseline no longer produced

filedrop.png — baseline no longer produced

form-errors.png — baseline no longer produced

heading.png — baseline no longer produced

img.png — baseline no longer produced

link.png — baseline no longer produced

menu.png — baseline no longer produced

metric-pill-tag-timeselect-text.png — baseline no longer produced

options.png — baseline no longer produced

pagination.png — baseline no longer produced

progressbar.png — baseline no longer produced

select-simpleselect.png — baseline no longer produced

table.png — baseline no longer produced

tabs.png — baseline no longer produced

tooltip.png — baseline no longer produced

treebrowser.png — baseline no longer produced

view.png — baseline no longer produced

Baselines come from the visual-baselines branch. They refresh on every merge to master.

github-actions Bot pushed a commit that referenced this pull request Jul 31, 2026
@balzss
balzss requested review from joyenjoyer and a lite review from Copilot and removed request for Copilot August 5, 2026 09:28

@joyenjoyer joyenjoyer left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please reduce the commit message, it is quite long and verbose


import { render, screen } from '@testing-library/react'
import { MockInstance, vi } from 'vitest'
// v1 accepts a plain ReactNode caption as well as the caption function that v2

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Overly verbose, messy comment, please remove

@balzss
balzss force-pushed the fix/ui-table-unsorted-caption-v1 branch from 1b12f46 to e7ad1e7 Compare August 13, 2026 12:11
@balzss
balzss requested review from ToMESSKa and joyenjoyer August 13, 2026 12:12
`getCaptionText` lost its `if (!sortInfo) return caption` early return in
aac2b17 (#2574), so every unsorted v1 Table with a plain string caption
rendered ' Sorted by undefined (undefined)' into its <caption> and its
aria-label. First shipped in v11.7.4; reported by canvas-lms.

Restore the early return, leaving the function-caption branch untouched.
Also add a v1 test suite — v1 had no coverage, which is why this shipped.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
github-actions Bot pushed a commit that referenced this pull request Aug 13, 2026
@balzss
balzss force-pushed the fix/ui-table-unsorted-caption-v1 branch from e7ad1e7 to b97c098 Compare August 13, 2026 12:23
github-actions Bot pushed a commit that referenced this pull request Aug 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants