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

Tile + TileGroup Accessibility #4606

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
title: Accessibility
redirect_from:
- /components/tile/accessibility/
---

# Accessibility

## Tile

The Tile component has been designed with accessibility in mind.

The component offers flexibility in terms of the HTML element used for the root node. By default, it will render a `div` element.

### Expandable / Clickable

The prop `expandable` makes the Tile clickable. In that case, assistive props like `ariaExpanded` are handled automatically.
Copy link
Contributor

Choose a reason for hiding this comment

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

I would maybe use aria-expanded here as that's the name and it's not a custom one, wdyt?


The component will render, by default, a `div` element with `role="button"` and `tabindex={0}`.

This also happens when the `onClick` prop is defined.

For that reason, one should refrain from using other interactive elements inside the Tile, like buttons or links, including on the `header` prop.

### Href

When the `href` prop is defined, the Tile will render an `a` element inside of the `div`.
For the same reason as above, one should refrain from using other interactive elements inside the Tile.

### HTML Title

The `htmlTitle` prop can be used to add extra information to the Tile.

It will be added as the `title` attribute to the root element (the `div` with `role="button"`) when the `expandable` is truthy or `onClick` is defined, or to the `a` element when the `href` prop is defined.
Copy link
Contributor

@domihustinova domihustinova Jan 31, 2025

Choose a reason for hiding this comment

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

It will be added as the title attribute to the root element (the div with role="button") when the expandable is truthy

Is this correct? When the expandable is truthy, we render TileExpandable which then passes htmlTitle to TileWrapper but then inside the TileWrapper, title with htmlTitle is set only on the a element, not also on WrapperComponent. Or maybe I am looking at the wrong place 🙈

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
title: Accessibility
redirect_from:
- /components/tilegroup/accessibility/
---

# Accessibility

## TileGroup

The TileGroup component has been designed with accessibility in mind.

The component offers flexibility in terms of the HTML element used for the root node. By default, it will render a `div` element.

If needed, it can be rendered as a list by passing the `as` prop with the value `"ul"`.

In that case, the `Tile` elements used as `children` should be rendered as `li`.

```jsx
<TileGroup as="ul">
<Tile title="Title" as="li" />
<Tile title="Title" as="li" />
</TileGroup>
```
7 changes: 3 additions & 4 deletions packages/orbit-components/src/Tile/Tile.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ export const DefaultWithHeaderPropsAsHref: Story = {

args: {
...DefaultWithHeaderProps.args,
onClick: undefined,
href: "https://www.kiwi.com/",
external: true,
},
Expand All @@ -114,10 +115,8 @@ export const ExpandableWithCustomDescription: StoryObj<
<Stack justify="between" align="center" direction="row" shrink>
<Stack spacing="none" direction="column" shrink>
<Stack direction="row" align="center" spacing="200">
<Heading type="title4" as="h4">
Mr. Hot potato
</Heading>
<CountryFlag code="cz" />
<Heading type="title4">Mr. Hot potato</Heading>
<CountryFlag code="cz" name="Czechia" />
</Stack>
<Text>13/37/1337</Text>
</Stack>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,7 @@ const TileHeader = ({
<Stack spacing="none" direction="column" shrink>
{title && (
<div className="flex w-full items-center">
<Heading type="title4" as="h3">
{title}
</Heading>
<Heading type="title4">{title}</Heading>
</div>
)}
{description && (
Expand Down
6 changes: 2 additions & 4 deletions packages/orbit-components/src/TileGroup/TileGroup.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,8 @@ export const Playground: Story = {
<Stack justify="between" align="center" direction="row" shrink>
<Stack spacing="none" direction="column" shrink>
<Stack direction="row" align="center" spacing="200">
<Heading type="title4" as="h4">
Mr. Hot potato
</Heading>
<CountryFlag code="cz" />
<Heading type="title4">Mr. Hot potato</Heading>
<CountryFlag code="cz" name="Czechia" />
</Stack>
<Text>13/37/1337</Text>
</Stack>
Expand Down
2 changes: 1 addition & 1 deletion packages/orbit-components/src/utils/Slide/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class Slide extends React.Component<Props, State> {
// eslint-disable-next-line jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events
<div
className={cx(
"orbit-slide relative w-full",
"orbit-slide relative w-full cursor-default",
transitionDuration && "transition-[max-height] ease-linear",
transitionDuration && getTransitionDurationClass(transitionDuration),
!transitionFinished && "overflow-hidden",
Expand Down