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

fix(react): file tree's files to indicate selected state #268

Merged
merged 2 commits into from
Aug 20, 2024

Conversation

AriPerkkio
Copy link
Member

Adds attribute to file element's button's so that it can be seen which file is currently selected/active.

Copy link

stackblitz bot commented Aug 20, 2024

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

return (
<button
className={`flex items-center gap-2 w-full pr-2 border-2 border-transparent text-faded ${className ?? ''}`}
style={{ paddingLeft: `${12 + depth * NODE_PADDING_LEFT}px` }}
onClick={() => onClick?.()}
aria-pressed={ariaPressed === true ? 'true' : undefined}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't 100% correct either as these are not toggle buttons, but it's better than nothing. Proper way would be to throw these buttons away and create a proper tree: https://www.w3.org/WAI/ARIA/apg/patterns/treeview/

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current representation though is much more efficient and much simpler than a tree.

Copy link
Member Author

@AriPerkkio AriPerkkio Aug 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simpler sure, but not accessible as it's not semantic. Assistive technologies are unable to detect these as file trees - it's just multiple buttons, not even a list. If we some day want to make this accessible, we should check how vscode.dev for example does this.

image

@Nemikolh Nemikolh merged commit bd8a3be into stackblitz:main Aug 20, 2024
9 checks passed
@AriPerkkio AriPerkkio deleted the fix/file-tree-selected-file branch August 20, 2024 11:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants