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

Define strategy how to transfer HTML attributes to the component and accordingly modify the TabsItem component #497

Merged
merged 1 commit into from
Oct 12, 2023
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
8 changes: 8 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,14 @@ 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
mbohal marked this conversation as resolved.
Show resolved Hide resolved
be observed:
1. If the component internally instantiates one or more interactive
(clickable/editable) elements, the attributes should be forwarded to
all of them.
2. 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