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

UI: Add a 'main' role to the Main component for a11y #13827

Merged
merged 1 commit into from
Feb 11, 2021
Merged
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
2 changes: 1 addition & 1 deletion lib/ui/src/components/layout/container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export const Main: FunctionComponent<{ isFullscreen: boolean; position: CSSPrope
position = undefined,
...props
}) => (
<Pane style={position} top {...props}>
<Pane style={position} top {...props} role="main">
Copy link
Contributor

@jsomsanith jsomsanith Feb 6, 2021

Choose a reason for hiding this comment

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

This is totally correct so I approved. But as a suggestion, a better way would be to render a ˋmain` element

Via styled component « as »

Suggested change
<Pane style={position} top {...props} role="main">
<Pane style={position} top {...props} as="main">

The same can be applied to the sidebar to render a nav element

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great suggestions! I'm hoping to use this one as an example, but then I'd like this approach to be spread so that most if not all major UI elements have landmarks set like this. I'll make the as update after testing to confirm axe picks it up correctly.

Copy link
Member

Choose a reason for hiding this comment

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

@jsomsanith we're using emotion not styled components ... not sure that makes a difference? 🤷‍♂️

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the precision. Emotion has the « as » props as well 🙂

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 took me a bit longer to get back to than expected, but from what I can tell, as can't be used for this type of element:

Type '{ children: Element; as: string; style: CSSProperties; top: true; }' is not assignable to type 'IntrinsicAttributes & ClassAttributes<HTMLDivElement> & HTMLAttributes<HTMLDivElement> & Pick<...> & { ...; } & { ...; }'.
  Property 'as' does not exist on type 'IntrinsicAttributes & ClassAttributes<HTMLDivElement> & HTMLAttributes<HTMLDivElement> & Pick<...> & { ...; } & { ...; }'.ts(2322)

<Paper isFullscreen={isFullscreen}>{children}</Paper>
</Pane>
);
Expand Down