fix(detaillist/text): L3-10789 improve semantic HTML to remove accessibility violations with <dl and <label#771
Conversation
✅ Deploy Preview for phillips-seldon ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
🚀 Storybook preview is ready. • Preview: https://68b9f094608b90f3cfec5a06-bxkrfrvquq.chromatic.com/ |
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the DetailList and Detail components to address accessibility violations by replacing semantic dictionary list elements (<dl>, <dt>, <dd>) with generic <div> elements, and changes the default HTML element for label text variants from <label> to <span> to prevent invalid nested label structures.
Key Changes:
- Moved
DetailListfromsrc/patterns/tosrc/components/and changed it from<dl>to<div> - Updated
Detailcomponent to use<div>elements instead of<dt>/<dd> - Changed Text component's default element for label variants from
<label>to<span>, requiring explicitelement="label"when used with form inputs
Reviewed Changes
Copilot reviewed 11 out of 18 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/patterns/ObjectTile/ObjectTile.tsx | Updated import path for DetailList from patterns to components |
| src/patterns/BidSnapshot/BidSnapshot.tsx | Updated import path for DetailList from patterns to components |
| src/index.ts | Updated exports to reference DetailList from components (contains duplicate export issue) |
| src/components/Text/utils.ts | Changed default element for label variants from 'label' to 'span' |
| src/components/Text/utils.test.ts | Updated test expectation and description for label variant |
| src/components/Text/types.ts | Reordered TextVariants enum - moved new variants to top |
| src/components/DetailList/utils.tsx | Added utility function for generating Detail component keys |
| src/components/DetailList/utils.test.tsx | Added tests for getDetailKey utility (contains type error) |
| src/components/DetailList/types.ts | Added DetailListAlignment enum definition |
| src/components/DetailList/index.ts | Added barrel export for DetailList component |
| src/components/DetailList/_detailList.scss | Added SCSS styles for DetailList component (contains selector typo) |
| src/components/DetailList/DetailList.tsx | Moved component from patterns, changed dl to div, added utilities (has multiple issues) |
| src/components/DetailList/DetailList.test.tsx | Added basic tests for DetailList (needs more coverage) |
| src/components/DetailList/DetailList.stories.tsx | Added Storybook stories for DetailList (incorrect category path) |
| src/components/Detail/Detail.tsx | Changed dt/dd elements to div elements |
| src/components/Detail/Detail.test.tsx | Updated test queries to match new div structure |
| src/components/DescriptiveRadioButton/DescriptiveRadioButton.tsx | Added explicit element="label" to Text component (creates invalid nested labels) |
| src/componentStyles.scss | Moved DetailList SCSS import from patterns to components |
Comments suppressed due to low confidence (3)
src/components/DetailList/DetailList.tsx:9
- Remove this leftover scaffolding comment. The interface has already been updated to use
ComponentProps<'div'>.
src/components/DetailList/DetailList.tsx:35 - The Storybook Link references
patterns-detaillistbut the component has been moved to components. Update the link to:https://phillips-seldon.netlify.app/?path=/docs/components-detaillist--overview
src/components/DetailList/DetailList.tsx:55 - Props are spread twice:
{...commonProps}on line 48 and{...props}on line 55. This causes props to be duplicated andcommonPropsvalues to be overridden byprops. SincecommonPropsalready contains necessary props extracted bygetCommonProps, remove the{...props}spread on line 55 to avoid unintended overrides.
src/components/DescriptiveRadioButton/DescriptiveRadioButton.tsx
Outdated
Show resolved
Hide resolved
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
✅ Deploy Preview for phillips-seldon ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
…
Jira ticket
L3-10789
Summary
This pull request refactors the
DetailListcomponent, moving it from thepatternsdirectory tocomponents, and updates its implementation to use adivinstead of adlelement. It also adjusts related imports throughout the codebase and updates theDetailcomponent to usedivelements instead ofdt/dd. Additionally, there are minor changes to theTextcomponent's default element logic and its variants forTextVariants.label*so we don't render<labelby default since we're now using that token for more than input labels. The<Inputtype components should always passelement='label'now for their labels.Change List (describe the changes made to the files)
Component Refactoring and Relocation
DetailListfromsrc/patterns/DetailList/DetailList.tsxtosrc/components/DetailList/DetailList.tsx, and changed its top-level element fromdltodiv, updating its props and implementation accordingly. [1] [2] [3] [4]DetailListfrom the newcomponentslocation instead ofpatterns, including insrc/index.ts,src/patterns/BidSnapshot/BidSnapshot.tsx, andsrc/patterns/ObjectTile/ObjectTile.tsx. [1] [2] [3] [4]DetailList. [1] [2]Detail Component Updates
Detailcomponent to usedivelements for labels and values instead of semanticdt/dd, and updated corresponding tests to match the new markup structure. [1] [2] [3]Text Component Improvements
labelvariants in theTextcomponent fromlabeltospan, and updated the related test and utility function. [1] [2]DescriptiveRadioButtonto explicitly setelement="label"for label text.Text Variants Reorganization
TextVariantsinsrc/components/Text/types.tsfor clarity; no functional changes to the available variants. [1] [2]Acceptance Test (how to verify the PR)
Regression Test
Evidence of testing
Before:

After

Things to look for during review
feat(scope): ...if aminorrelease should be triggered.phillipsclass prefix are using the prefix variabledata-testidattribute.New Components
index.tsfilecomponentStyles.scssfile.