Repository navigation
fix(ui-table): don't stringify non-string captions on v1 - #2836
Merged
Merged
Conversation
Contributor
|
Contributor
Visual regression reportCypress suite: ✅ Passing Visual diff: ✅ No changes.
Accessibility (axe): ✅ No violations. 📊 View full report — click a screenshot's ⚠ badge to see each violation boxed on the image, with the offending element named and contrast failures shown as color swatches. Baselines come from the |
`getCaptionText` cast `caption` to a string, so a sorted v1 Table with a
ReactNode caption rendered "[object Object] Sorted by Foo (ascending)"
into its <caption>, its aria-label and the live region announcement.
Return non-string captions unchanged, as the prop docs already say
("a plain ReactNode is rendered as-is and the sort state is ignored").
Only set aria-label and the live region text when the caption is a
string; the <caption> element still names the table.
matyasf
force-pushed
the
fix/ui-table-element-caption
branch
from
December 2, 2026 15:34
5ee4b47 to
04a442b
Compare
matyasf
self-requested a review
December 2, 2026 15:35
matyasf
approved these changes
Dec 2, 2026
balzss
approved these changes
Dec 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A sorted v1
Tablewith aReactNodecaption renders[object Object] Sorted by Foo (ascending)into its<caption>, itsaria-labeland the live region announcement.getCaptionTextcastscaptionto a string and concatenates the sort text onto it. Thecaptionprop docs already say a plainReactNodeis rendered as-is and the sort state is ignored; the v1 code didn't do that. v2 is unaffected (captionmust be a function there).Found in canvas-lms, where the accessibility checker passes
<ScreenReaderContent>as the caption (being fixed on their side to pass a string).Changes
Table/v1/index.tsx:getCaptionTextreturns non-string captions unchanged.aria-labeland the live region text are only set when the caption is a string; the<caption>element still names the table.Table/v1/__tests__/Table.test.tsx: add a sortedReactNodecaption test.Test Plan
[object Object] Sorted by Foo (ascending)) and passes with the fix.vitest --project browser packages/ui-table/src/Table/v1: 4 passed.ts:checkclean for ui-table.Not covered: the " Sorted by X (direction)" suffix is still hardcoded English for string captions. The function caption form is the localizable path.