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

feat(step-flow): add aria props to component - FE-7013 #7121

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

DipperTheDan
Copy link
Contributor

@DipperTheDan DipperTheDan commented Dec 9, 2024

Proposed behaviour

Aria props are destructured and present in the documentation for Step Flow

Current behaviour

Aria props are not destructured. They are present due to ...rest being spread on the component. Due to this, they do not appear in the Storybook documentation for the component under the Props section.

Checklist

  • Commits follow our style guide
  • Related issues linked in commit messages if required
  • Screenshots are included in the PR if useful
  • All themes are supported if required
  • Unit tests added or updated if required
  • Playwright automation tests added or updated if required
  • Storybook added or updated if required
  • Translations added or updated (including creating or amending translation keys table in storybook) if required
  • Typescript d.ts file added or updated if required
  • Related docs have been updated if required

QA

  • Tested in provided StackBlitz sandbox/Storybook
  • Add new Playwright test coverage if required
  • Carbon implementation matches Design System/designs
  • UI Tests GitHub check reviewed if required

Additional context

N/A

Testing instructions

New test stories have been created to demonstrate the newly added aria props. These stories are:

  • Default with aria-label
  • Default with aria-labelledby
  • Default with aria-describedby

You should be able to see these attributes in the DOM, on the element for Step Flow.

There should also be no other functional or styling regressions due to this change.

@@ -180,7 +195,14 @@ export const StepFlow = forwardRef<StepFlowHandle, StepFlowProps>(
);

return (
<StyledStepFlow {...rest} {...tagComponent("step-flow", rest)}>
<StyledStepFlow
role="group"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This role has been added because I saw an Axe warning of attribute is not well supported on a div with no valid role attribute when using the aria props. The role of group was what I thought fit this component. However, I am open to suggestions on which is best. A role of presentation or none triggers the Axe warning.

Copy link
Contributor

@nuria1110 nuria1110 left a comment

Choose a reason for hiding this comment

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

Looks good to me, just a couple non-blocking suggestions


const stepFlowComponent = screen.getByTestId("step-flow");

expect(stepFlowComponent).toHaveAttribute("aria-label", "foo");
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion (non-blocking): We could use the toHaveAccessbleName matcher here to ensure the accessible name has been correctly set.

Suggested change
expect(stepFlowComponent).toHaveAttribute("aria-label", "foo");
expect(stepFlowComponent).toHaveAccessibleName( "foo");


const stepFlowComponent = screen.getByTestId("step-flow");

expect(stepFlowComponent).toHaveAttribute("aria-labelledby", "foo");
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion (non-blocking): Same here


const stepFlowComponent = screen.getByTestId("step-flow");

expect(stepFlowComponent).toHaveAttribute("aria-describedby", "foo");
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion (non-blocking): Same here, we could use toHaveAccessibleDescription

@tomdavies73 tomdavies73 self-requested a review December 11, 2024 10:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

3 participants