-
Notifications
You must be signed in to change notification settings - Fork 371
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
fix: accessibility issue in tabs #1184
fix: accessibility issue in tabs #1184
Conversation
Review or Edit in CodeSandboxOpen the branch in Web Editor • VS Code • Insiders |
@shrilakshmishastry is attempting to deploy a commit to the CodeSandbox Team on Vercel. A member of the Team first needs to authorize it. |
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
<div | ||
aria-labelledby={`${activeFile}-tab`} | ||
className={classNames("code-editor", [editorClassName])} | ||
id={`${activeFile}-tab-panel`} |
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.
Considering that a page can contain multiple Sandpack instances with similar content, this ID will not be unique to the page. Is there any reason why you need an ID here? There is an alternative to generate unique identifier inside Sandpack
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.
yes, this ID is used inside the FileTabs
component, to add the aria-controls
attribute.
aria-controls={`${filePath}-tab-panel`} |
is there a way I can get a unique ID and pass it between FileTabs
and CodeEditor
?
One way I am thinking is to add a unique id with activeFile , what's your opinion ?
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 just introduced a new hook (useSandpackId
) to your branch and I think you could use it to generate ids
Hey @danilowoz 👋 Thanks for reviewing !! Did you get a chance to try it out ? |
I'm a bit hesitant about adding a ring focus over the code editor, giving the following reasons:
Let me know what you think :) |
Hey 👋 ,
|
feat: add unique id to each tab and tab panel for aria-* attributes
|
@@ -27,6 27,9 @@ export const editorClassName = css({ | |||
[`.${placeholderClassName}`]: { | |||
padding: "$space$4 0", | |||
}, | |||
"&:focus-within": { | |||
outline: "$colors$accent auto 1px", |
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.
@shrilakshmishastry, this can be implemented on your end, meaning inside the application that implements Sandpack, instead of adding a default style that might not be wanted by everyone. For a basic and generic experience, the editor already provides the necessary hint when it's focused, so I don't think adding such an opinionated style will be a good idea now.
For example, this can be added to your application:
.sp-code-editor:focus-within {
outline: 1px auto red;
}
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.
hmm, got it 👍 make sense, I will revert this
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.
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 looks good to me! But could you please check the Typescript job and fix the issues? |
In the refactor: make activeFileUniqueId as optional paramater in FileTabs commit,
@danilowoz can you please re-review ? |
Issue:
tab
, but the tab accessibility pattern is not taken care.Issues noticed:
Fixed:
basic tab accessibility pattern :
on the focus of the tab, close CTA is visible and is keyboard accessible
Screen recording
Tab pattern implementation
https://github.com/user-attachments/assets/6221d6dd-1050-486c-adb6-9e2e6b1420f2
Editor accessibility
https://github.com/user-attachments/assets/7049baa6-762d-4015-85b6-21fd20a20f41
What kind of change does this pull request introduce?
Checklist
This fix partially #1173