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(SelectPanel2): only bind keydown event when necessary #4601

Merged
merged 2 commits into from
May 22, 2024

Conversation

bwittenberg
Copy link
Contributor

Closes #4581

Changelog

New

  • Adds additional jest test coverage for the SelectPanel

Changed

  • Adds optimization to SelectPanel so that event listeners are not added and removed on each render, but only when the effect dependencies change.

Removed

Rollout strategy

  • Patch release
  • Minor release
  • Major release; if selected, include a written rollout or migration plan
  • None; if selected, include a brief description as to why

Testing & Reviewing

  • One of the SelectPanel jest test should fail if changes to SelectPanel are reverted.
  • RT1: Regression Test 1: Panel should close when opened and escape is pressed
    • Visit the SelectPanel in storybook (http:///?path=/story/drafts-components-selectpanel--default)
    • Click the button, assert panel opens
    • Press the Escape key on the keyboard, assert panel closes

Merge checklist

  • Added/updated tests
    - [ ] Added/updated documentation
    - [ ] Added/updated previews (Storybook)
  • Changes are SSR compatible
    • I'm not sure about this one. Because hooks with dependencies are in use already, this code change shouldn't introduce any issues. I didn't test though, which is why I'm not checking this box.
  • Tested in Chrome (ran RT1 above on Chrome 124.0.6367.207)
  • Tested in Firefox (ran RT1 above on Firefox 126.0)
  • Tested in Safari (ran RT1 on Safari 17.4.1)
  • Tested in Edge (ran RT1 on Edge 124.0.2478.105)
  • (GitHub staff only) Integration tests pass at github/github (Learn more about how to run integration tests)

@bwittenberg bwittenberg requested a review from a team as a code owner May 16, 2024 17:14
Copy link

changeset-bot bot commented May 16, 2024

🦋 Changeset detected

Latest commit: f332218

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@primer/react Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@bwittenberg bwittenberg marked this pull request as draft May 16, 2024 17:16
Copy link
Member

@broccolinisoup broccolinisoup left a comment

Choose a reason for hiding this comment

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

Hello @bwittenberg 👋🏻 Thanks for pushing this PR! It looks good to me 👍🏻 I'll just ping @siddharthkp since he has greater context on SelectPanel to see if there is any concern from him!

@bwittenberg
Copy link
Contributor Author

Hello @broccolinisoup! Appreciate the 👀. If you'd like to see any changes, I'm happy to make revisions.

Copy link
Member

@siddharthkp siddharthkp left a comment

Choose a reason for hiding this comment

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

Looks good to me!

Copy link
Member

@broccolinisoup broccolinisoup left a comment

Choose a reason for hiding this comment

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

🎉

@broccolinisoup broccolinisoup added this pull request to the merge queue May 22, 2024
Merged via the queue into primer:main with commit f57dd3d May 22, 2024
28 checks passed
@primer primer bot mentioned this pull request May 22, 2024
@bwittenberg bwittenberg deleted the bwittenberg/4581 branch May 22, 2024 11:49
khiga8 pushed a commit that referenced this pull request May 31, 2024
* fix(SelectPanel2): only bind keydown event when necessary

* chore(SelectPanel2): Add changeset
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.

SelectPanel2 Optimization: Do not add and remove keydown listener for escape key on every render
3 participants