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

[#2130] Changed the keyboard navigation for the Accordion component t… #2198

Merged
merged 7 commits into from
Nov 6, 2022

Conversation

MuhammadAakash
Copy link
Contributor

@MuhammadAakash MuhammadAakash commented Nov 4, 2022

Description

More Details

I have changed the keyboard navigation of Accordion from TAB to ENTER

Corresponding Issue

#2130

Screenshots


Reviewing this pull request? Check out our Code Review Practices guide if you haven't already!

@welcome
Copy link

welcome bot commented Nov 4, 2022

Thank you for opening this pull request with us! Be sure to follow our Pull Request Practices. Let us know if you have any questions on Slack.

Copy link
Member

@julianguyen julianguyen left a comment

Choose a reason for hiding this comment

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

Awesome work! Thanks so much for taking this on. A few comments and we should be good to go 🎉

@@ -43,14 +43,19 @@ export const Accordion = ({
setOpen(!open);
};

const openToggle = (event: any) => {
Copy link
Member

Choose a reason for hiding this comment

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

Let's specify the type here, it should be SyntheticKeyboardEvent<HTMLDivElement>.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@julianguyen Thanks for mentioning it.
I have updated the file.

const inputClassNames = () => `${dark ? css.dark : ''} ${large ? css.large : ''}`;

return (
<div id={`${id}_accordion`} className={inputClassNames()}>
<div
className={`accordion ${globalCss.gridRowSpaceBetween} ${css.accordion}`}
onClick={toggleOpen}
onKeyDown={toggleOpen}
onKeyDown={openToggle}
Copy link
Member

Choose a reason for hiding this comment

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

Let's also write a test for this in client/app/components/Accordion/__tests__/Accordion.spec.jsx! If you need help on writing this, here's a similar test for the Modal component.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@julianguyen
I haven't written any test cases yet.
Can you please explain how to write them..

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @julianguyen
I have added the test case. Please have a look now, and let me know if anything needs to be changed.

Copy link
Member

@julianguyen julianguyen left a comment

Choose a reason for hiding this comment

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

Great work, thanks so much 🎉

Copy link
Member

@julianguyen julianguyen left a comment

Choose a reason for hiding this comment

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

Thanks for the updates! Have more feedback!


const accordionContent = getByRole('region');
const accordionBtn = getByRole('button');
fireEvent.keyDown(accordionContent, {
Copy link
Member

Choose a reason for hiding this comment

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

You want to trigger the Enter key on the accordionBtn not accordionContent. After doing that, expect(accordionContent).toHaveClass('accordionContent'); should pass. expect(accordionContent).toHaveClass('accordionClose'); should only pass once the accordion is closed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, @julianguyen I haven't written any test cases before that's why it is taking some time. Hopefully, it's completed now.

Copy link
Member

@julianguyen julianguyen left a comment

Choose a reason for hiding this comment

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

Awesome work!!

@julianguyen julianguyen merged commit 2b4d21f into ifmeorg:main Nov 6, 2022
@welcome
Copy link

welcome bot commented Nov 6, 2022

Thank you for merging this pull request with us! If you haven't already, in another pull request, please add yourself to our About page.

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