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 keyboard highlighting with open/close feature #349

Merged
merged 5 commits into from
Jan 25, 2024

Conversation

isaacknjama
Copy link
Contributor

This PR closes #324

Adds accessibility into collapsible fields by allowing navigation using the keyboard.

Screenshot from 2024-01-15 22-15-54

image

image

@isaacknjama isaacknjama requested a review from a team as a code owner January 15, 2024 19:16
Copy link
Collaborator

@wbobeirne wbobeirne left a comment

Choose a reason for hiding this comment

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

cc @Kodylow to take a look at how this affects the behavior (clickable only on the right) and visuals (additional padding for arrow), make sure these changes are desirable.

The issue I opened was entirely just about the accessibility of it, so I want to make sure any additional changes are considered as well.

Comment on lines 35 to 36
tabIndex={1}
cursor='pointer'
Copy link
Collaborator

Choose a reason for hiding this comment

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

Making the cursor a pointer and giving it a tabIndex across the entire header may give a user the mistaken understanding that clicking this will open / collapse the header, but only clicking the button inside will.

Copy link
Member

Choose a reason for hiding this comment

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

I think if it's collapsed having it be "click anywhere" is preferable

packages/ui/src/FormGroupHeading.tsx Outdated Show resolved Hide resolved
>
{icon && <Icon width='20px' height='20px' mr={2} as={icon} />}
<Heading fontSize='md' lineHeight='20px' fontWeight='700'>
{title}
</Heading>
<Spacer />
{chevronIcon}
<Button onClick={onClick} tabIndex={1} variant='ghost' color='black'>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Buttons don't need a tabIndex, they're tabbable by default.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Choosing to use the Chakra <Button> component added some new styling here that adds padding that wasn't there before. Maybe this is desirable, but it's a change worth considering.

Copy link
Collaborator

Choose a reason for hiding this comment

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

While I think the padding unintentionally introduced by the button is pleasant, the button adds a tab stop that's redundant to the functionality of the form group header and we should not introduce it

Copy link
Collaborator

Choose a reason for hiding this comment

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

in case we decide to keep the button, it should also have an onKeydown listener

Copy link
Collaborator

@wbobeirne wbobeirne Jan 24, 2024

Choose a reason for hiding this comment

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

onClick already captures the typical accessibility keys for proceeding when focused (space bar, enter etc)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sorry, I was mistaken. That is only the case if you use proper elements. Even adding accessibility attributes like tabIndex and role don't work if it's not a button or a: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/button_role#required_javascript_features

Although for what it's worth, that's a reason to get the element to use the right element instead of using a div and trying to turn it into an accessible clickable element. This would be a lot easier if it was just a <button>.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Refactoring this to Button element seems to work just fine. No redundant functionality with tab stop, and open/close works for both onClick and keydown (Enter and Space bar) without explicitly specifying this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

refactor.to.button.element.webm

@Kodylow
Copy link
Member

Kodylow commented Jan 16, 2024

echo all nits by will, and click to open should be the whole bar not just the arrow if we're updating anyway.

@okjodom
Copy link
Collaborator

okjodom commented Jan 23, 2024

currently validating the latest iteration

mb={3}
bg={theme.colors.gray[100]}
color={theme.colors.white[100]}
Copy link
Collaborator

Choose a reason for hiding this comment

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

try apply the right button variant and colors so we fix A11y without changing visible UI. Something like variant='ghost'+ bg={theme.colors.gray[100]} + text color modification should work

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Side note: Open/Close on Follower isn't that graceful. Effect of having less fields?

@Kodylow
Copy link
Member

Kodylow commented Jan 25, 2024

just test with jodom, approving and merging

Copy link
Member

@Kodylow Kodylow left a comment

Choose a reason for hiding this comment

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

approve

@Kodylow Kodylow merged commit 098053f into fedimint:master Jan 25, 2024
1 check passed
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.

Collapsible fields lack accessibility
4 participants