-
Notifications
You must be signed in to change notification settings - Fork 152
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
Make Table accessible #4629
Make Table accessible #4629
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Key Issues
The handleScroll
function lacks cleanup in the useEffect hook, risking memory leaks during frequent table re-renders.
Storybook staging is available at https://kiwicom-orbit-domi-table.surge.sh Playroom staging is available at https://kiwicom-orbit-domi-table.surge.sh/playroom |
Size Change: +83 B (+0.02%) Total Size: 461 kB
ℹ️ View Unchanged
|
Deploying orbit with
|
Latest commit: |
14f7649
|
Status: | ✅ Deploy successful! |
Preview URL: | https://065ac890.orbit.pages.dev |
Branch Preview URL: | https://domi-table.orbit.pages.dev |
af86f48
to
4a0d240
Compare
docs/src/documentation/03-components/02-structure/table/03-accessibility.mdx
Show resolved
Hide resolved
docs/src/documentation/03-components/02-structure/table/03-accessibility.mdx
Show resolved
Hide resolved
docs/src/documentation/03-components/02-structure/table/03-accessibility.mdx
Outdated
Show resolved
Hide resolved
docs/src/documentation/05-development/04-migration-guides/01-v20.mdx
Outdated
Show resolved
Hide resolved
docs/src/documentation/05-development/04-migration-guides/01-v20.mdx
Outdated
Show resolved
Hide resolved
@@ -137,6 +137,14 @@ intl.formatMessage({ | |||
|
|||
Feel free to customize the translations according to your needs, by eventually providing more context to the modal it refers to. | |||
|
|||
## Fixes | |||
|
|||
### `scope` prop in the `TableCell` can now be set only for the `th` element (from version 20.1.0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to be careful with this, as we're not 100% sure we will release 20.1.0 next. For instance:
- I have a BC in the Alert PR, which would result in 21.0.0. Not sure if it will be merged on time
- This PR has only fixes, which would result in a patch version 20.0.1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we will wait till next release to update this accordingly? 🎗️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's leave it like this (we can change it to 20.0.1) and set a reminder before the release to adjust it 🤝
Edit: I set a reminder at 9:30 Thu on my side, you can do the same :)
c51d32c
to
a3c6bbe
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Key Issues
The PR review highlights a critical accessibility issue where the scope
attribute is missing from table header cells when as
is set to TYPE_AS.TH
, which can hinder screen reader functionality.
@@ -40,7 +41,7 @@ const TableCell = ({ | |||
(align === ALIGN_OPTIONS.END || align === ALIGN_OPTIONS.RIGHT) && "text-end", | |||
)} | |||
data-test={dataTest} | |||
scope={scope} | |||
scope={props.as === TYPE_AS.TH ? props.scope : undefined} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🐛 Possible Bug
When as
is set to TYPE_AS.TH
, the scope
attribute should be required for accessibility. Currently, the code allows table header cells without a scope attribute, which can make the table less accessible for screen readers. The scope attribute helps screen readers understand the relationship between header cells and data cells.
scope={props.as === TYPE_AS.TH ? props.scope : undefined} | |
scope={props.as === TYPE_AS.TH ? (props.scope || 'col') : undefined} |
a3c6bbe
to
14f7649
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Key Issues
Event handling changes could lead to unexpected event bubbling and unwanted parent handler triggers due to altering stopPropagation()
to preventDefault()
. Setting stopClickPropagation={false}
on the Slide component may cause event bubbling issues as it deviates from the default behavior. Using ev.code
instead of ev.keyCode
might cause compatibility issues in older browsers, necessitating a fallback mechanism.
I didn't find any wrong usage of
scope
in the repositories so the problem was most likely only in our stories. But to prevent wrong usage in the future, I changed the types to allowscope
only forth
element. I added it to migration guide as a note for the users to be aware of it as advised by Marco.Closes https://kiwicom.atlassian.net/browse/FEPLT-2243
✨
Description by Callstackai
This PR enhances the accessibility of the Table component by restricting the usage of the
scope
prop to only theth
element. It also updates the documentation and migration guide accordingly.Diagrams of code changes
Files Changed
scope
attribute.scope
prop to theth
element.children
prop in the Table component documentation.TableCell
component to conditionally apply thescope
prop based on theas
prop.Props
type to restrict thescope
prop to only be used with theth
element.This PR includes files in programming languages that we currently do not support. We have not reviewed files with the extensions
.mdx
,.md
. See list of supported languages.