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(radio-group): onChange event not triggering on keyboard navigation #3592

Merged
merged 2 commits into from
Aug 25, 2023

Conversation

Rajdeepc
Copy link
Contributor

@Rajdeepc Rajdeepc commented Aug 25, 2023

Description

Added onChange trigger when radio buttons are navigated via keyboard in a radio-group

Related issue(s)

Motivation and context

How has this been tested?

  • Test case 1
    1. Go here
    2. Do this
  • Test case 2
    1. Go here
    2. Do this

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Chore (minor updates related to the tooling or maintenance of the repository, does not impact compiled assets)

Checklist

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • If my change required a change to the documentation, I have updated the documentation in this pull request.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • I have reviewed at the Accessibility Practices for this feature, see: Aria Practices

Best practices

This repository uses conventional commit syntax for each commit message; note that the GitHub UI does not use this by default so be cautious when accepting suggested changes. Avoid the "Update branch" button on the pull request and opt instead for rebasing your branch against main.

@Rajdeepc Rajdeepc added bug Something isn't working a11y Issues related to accessibility Component: Radio labels Aug 25, 2023
@Rajdeepc Rajdeepc requested a review from Westbrook August 25, 2023 08:17
@Rajdeepc Rajdeepc changed the title fix(radio-group): onchange trigger fix(radio-group): onChange event not triggering on keyboard navigation Aug 25, 2023
@github-actions
Copy link

github-actions bot commented Aug 25, 2023

Tachometer results

Chrome

radio permalink

Version Bytes Avg Time vs remote vs branch
npm latest 400 kB 193.15ms - 197.54ms - faster ✔
0% - 4%
0.40ms - 8.00ms
branch 395 kB 196.44ms - 202.65ms slower ❌
0% - 4%
0.40ms - 8.00ms
-
Firefox

radio permalink

Version Bytes Avg Time vs remote vs branch
npm latest 400 kB 343.32ms - 367.56ms - unsure 🔍
-6% - +4%
-22.20ms - +13.72ms
branch 395 kB 346.43ms - 372.93ms unsure 🔍
-4% - +6%
-13.72ms - +22.20ms
-

Copy link
Collaborator

@najikahalsema najikahalsema left a comment

Choose a reason for hiding this comment

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

Could we get a test in Radio Group for this fix?

I don't know if we've explicitly discussed this, but it's best practise to write a test when making bug fixes so that we know it's actually fixed and can make sure other additions to the code don't cause our tests to fail. The best way to test this is to write the test before making changes (it will fail), make the change, and watch the test succeed!

the test I'd recommend for this is it("emits change events on arrow key events"). You can use the sinon/spy package to check the callCount of the change event to make sure it emits as expected.

Let me know if you have more questions!

@Rajdeepc Rajdeepc requested a review from najikahalsema August 25, 2023 18:59
Copy link
Collaborator

@najikahalsema najikahalsema left a comment

Choose a reason for hiding this comment

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

Great! Thank you ☺️

@najikahalsema najikahalsema merged commit 8501239 into main Aug 25, 2023
@najikahalsema najikahalsema deleted the bug/radio-group-onchange branch August 25, 2023 19:05
jianliao pushed a commit that referenced this pull request Aug 28, 2023
#3592)

* fix(radio): onchange trigger

* test: added test for change events on arrow key events

---------

Co-authored-by: Rajdeep Chandra <[email protected]>
blunteshwar pushed a commit that referenced this pull request Sep 12, 2023
#3592)

* fix(radio): onchange trigger

* test: added test for change events on arrow key events

---------

Co-authored-by: Rajdeep Chandra <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a11y Issues related to accessibility bug Something isn't working Component: Radio
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Using arrow keys to toggle buttons in an Radio Group does not trigger change event
2 participants