Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addon-a11y: added 'name' param for generate unique key for item #6118

Merged
merged 1 commit into from
Mar 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions addons/a11y/src/components/A11YPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,17 +165,29 @@ export class A11YPanel extends Component<A11YPanelProps, A11YPanelState> {
{
label: <Violations>{violations.length} Violations</Violations>,
panel: (
<Report passes={false} items={violations} empty="No a11y violations found." />
<Report
name="violations"
passes={false}
items={violations}
empty="No a11y violations found."
/>
),
},
{
label: <Passes>{passes.length} Passes</Passes>,
panel: <Report passes items={passes} empty="No a11y check passed." />,
panel: (
<Report name={'passes'} passes items={passes} empty="No a11y check passed." />
),
},
{
label: <Incomplete>{incomplete.length} Incomplete</Incomplete>,
panel: (
<Report passes={false} items={incomplete} empty="No a11y incomplete found." />
<Report
name="incomplete"
passes={false}
items={incomplete}
empty="No a11y incomplete found."
/>
),
},
]}
Expand Down
5 changes: 3 additions & 2 deletions addons/a11y/src/components/Report/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ export interface ReportProps {
items: Result[];
empty: string;
passes: boolean;
name: string;
}

export const Report: FunctionComponent<ReportProps> = ({ items, empty, passes }) => (
export const Report: FunctionComponent<ReportProps> = ({ items, empty, passes, name }) => (
<Fragment>
{items.length ? (
items.map(item => <Item passes={passes} item={item} key={item.id} />)
items.map(item => <Item passes={passes} item={item} key={`${name}:${item.id}`} />)
) : (
<Placeholder key="placeholder">{empty}</Placeholder>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -962,6 +962,7 @@ exports[`A11YPanel should render report 1`] = `
"panel": <Unknown
empty="No a11y violations found."
items={Array []}
name="violations"
passes={false}
/>,
},
Expand All @@ -973,6 +974,7 @@ exports[`A11YPanel should render report 1`] = `
"panel": <Unknown
empty="No a11y check passed."
items={Array []}
name="passes"
passes={true}
/>,
},
Expand All @@ -984,6 +986,7 @@ exports[`A11YPanel should render report 1`] = `
"panel": <Unknown
empty="No a11y incomplete found."
items={Array []}
name="incomplete"
passes={false}
/>,
},
Expand Down Expand Up @@ -1058,6 +1061,7 @@ exports[`A11YPanel should render report 1`] = `
<Component
empty="No a11y violations found."
items={Array []}
name="violations"
passes={false}
>
<Placeholder
Expand Down