-
Notifications
You must be signed in to change notification settings - Fork 486
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
LPS-201300 Fixing Accessibility Issue at Clay Panel Component #5716
Conversation
cea4627
to
76b7672
Compare
Hi @AkramYoussoufi , did you try using this component after your changes with your keyboard and a screen reader? You'll notice not much info is provided when interacting with a panel. We need these roles to make it work properly with accessible technologies. |
Hey @AkramYoussoufi , this change still won't work. It breaks the proper HTML semantics. Mozilla explains here:
Since you have removed the |
f45dfc4
to
59f8e81
Compare
@ethib137 in this changes, I have fixed the conflict happens between ClayGroupPanel and ClayPanelComponent Because the GroupPanel Component has its own role="tablist"
and on the ClayPanelComponent also has the this cause issue when using ClayPanelGroup and ClayPanel Component together ex:
in this scenario, the ClayPanelGroup will look for an element with I have added a checker which check if the GroupPanel is used as parent if yes in this case the ClayPanel will not use |
9448efd
to
9b5b89e
Compare
one problem present now is that ClayPanel Component uses the ClayPanel.Body as its own child this caused problems since the ClayPanel.Body has and must have the based on mozilla doc you gave me and devTools scanner and the ClayPanel Component is built to receive the ClayPanel.Body as its own child! based on the code source and this is the normal implementation :
we can fix this technically by making the
outside the ClayPanel ex:
like this ClayPanel will act as the tab while the ClayPanel.Body act as the tabpanel but still we will need to assign ClayPanel.Group as the parent to the ClayPanel with role="tablist" to be in the correct structure
like this we will have
as the right structure and ClayGroup will became a must use case for the ClayPanel |
9b5b89e
to
1fc4949
Compare
Hello @ethib137, disclosure pattern is implemented |
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.
Thanks @AkramYoussoufi . Couple things to change... Also the deploy preview is braking, so it would be good to look into why.
packages/clay-panel/src/index.tsx
Outdated
@@ -146,9 +146,9 @@ function ClayPanel({ | |||
show: internalExpanded, | |||
} | |||
)} | |||
data-disclosure |
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.
What is the purpose of adding this data attribute?
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.
It is a mark defining the pattern used in this element
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 removed it
packages/clay-panel/src/index.tsx
Outdated
@@ -135,6 +134,7 @@ function ClayPanel({ | |||
{collapsable && ( | |||
<> | |||
<ClayButton | |||
aria-controls="panel-body" |
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.
The value of aria-controls
needs to be the id of the element it controls.
https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-controls
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.
fixed!
5d98985
to
0b3ba3c
Compare
@ethib137 required pattern is implemented I added a logic that will look for the number of panels within the parent element and give each panel element its needed index within a group of panels. |
0b3ba3c
to
a91b228
Compare
@ethib137 I don't understand why the CI return failed on the test because the test in my local passed successfully:
|
a91b228
to
b296c1b
Compare
packages/clay-panel/src/index.tsx
Outdated
@@ -135,6 +151,7 @@ function ClayPanel({ | |||
{collapsable && ( | |||
<> | |||
<ClayButton | |||
aria-controls={`panel-index-${indexOfElement}`} |
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.
Hey @AkramYoussoufi can you look at other instances of how we generate an ID for aria-controls and copy that pattern?
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.
sure thing
b296c1b
to
e369936
Compare
@ethib137 Done! |
@@ -201,7 +204,6 @@ function ClayPanel({ | |||
onExiting={(element) => { | |||
element.style.height = ''; | |||
}} | |||
role="tabpanel" |
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 was talking to Marcos about this and one of the things we can follow here is to use the w3c accessibility recommendation for accordion which is similar to panel https://www.w3.org/WAI/ARIA/apg/patterns/accordion/examples/accordion/, we can add role="region"
here instead of tabpanel
. The other implementations part is ok too.
packages/clay-panel/package.json
Outdated
@@ -18,7 +18,7 @@ | |||
"build": "cross-env NODE_ENV=production babel src --root-mode upward --out-dir lib --extensions .ts,.tsx", | |||
"buildTypes": "cross-env NODE_ENV=production tsc --project ./tsconfig.declarations.json", | |||
"prepublishOnly": "yarn build && yarn buildTypes", | |||
"test": "jest --config ../../jest.config.js" | |||
"test": "jest --config ../../jest.config.js --updateSnapshot" |
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.
You can remove updateSnapshot
here, we don't want this command by default because it will make the snapshot unusable we should only use it when we intend to update the markup. If you maintain this, we can update in a snapshot in cases where the markup change is a bug.
e369936
to
45bd3eb
Compare
@matuzalemsteles @ethib137 all the changes have been implemented I don't understand what causes netlify to fail but my jest and build is working perfectly fine in my local. |
45bd3eb
to
e3c7573
Compare
e3c7573
to
30ca61c
Compare
Co-Authored-By: Akram Youssoufi <[email protected]>
30ca61c
to
6ffa238
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.
LGTM! These storybook and website errors don't make any sense, I'll go ahead and see if the builds still fail on master.
Ticket
Thread-Slack