Skip to content

Commit

Permalink
Define strategy how to transfer HTML attributes to the component and …
Browse files Browse the repository at this point in the history
…accordingly modify the `TabsItem` component
  • Loading branch information
mbohal committed Oct 12, 2023
1 parent fac60f3 commit 62a4f74
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
10 changes: 10 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,16 @@ To keep React UI consistent and predictable the following guidelines should be o
1. If component accepts the `children` prop it should be either required or the element
should return `null` when no children are provided.
2. When forwarding HTML attributes to the component the following rules should
be observed:
1. If the component internally instantiates an interactive
(clickable/editable) element, the attributes should be forwarded to it.
2. If the component internally instantiates multiple interactive
(clickable/editable) elements, the attributes should be forwarded to
them.
3. If the component does not internally instantiate an interactive
(clickable/editable) element, the attributes should be forwarded to the
root element of the component.
## Documenting
Expand Down
2 changes: 1 addition & 1 deletion src/components/Tabs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ React.createElement(() => {
In addition to the options below in the [component's API](#api) section, you
can specify [React synthetic events] or **any HTML attribute you like.** All
attributes that don't interfere with the API are forwarded to the `<nav>` HTML
element in case of `Tabs` component and to the `<li>` HTML element in
element in case of `Tabs` component and to the `<a>` HTML element in
case of `TabsItem`. This enables making the component interactive and helps
to improve its accessibility.

Expand Down
2 changes: 1 addition & 1 deletion src/components/Tabs/TabsItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export const TabsItem = ({
...restProps
}) => (
<li
{...transferProps(restProps)}
className={classNames(
styles.root,
isActive && styles.isRootActive,
Expand All @@ -25,6 +24,7 @@ export const TabsItem = ({
key={href}
>
<a
{...transferProps(restProps)}
className={styles.link}
href={href}
id={id && `${id}__link`}
Expand Down

0 comments on commit 62a4f74

Please sign in to comment.