Skip to content

Conversation

francinelucca
Copy link
Member

Relates to https://github.com/github/primer/issues/5882

Changelog

New

  • Add KeyboardEventHandler to overlayProps in SelectPanel to prevent event bubbling

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

Merge checklist

@francinelucca francinelucca requested a review from a team as a code owner September 23, 2025 20:08
Copy link

changeset-bot bot commented Sep 23, 2025

🦋 Changeset detected

Latest commit: b34a87e

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

This PR includes changesets to release 2 packages
Name Type
@primer/react Patch
@primer/styled-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

@github-actions github-actions bot added the staff Author is a staff member label Sep 23, 2025
@github-actions github-actions bot added the integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm label Sep 23, 2025
Copy link
Contributor

👋 Hi, this pull request contains changes to the source code that github/github depends on. If you are GitHub staff, we recommend testing these changes with github/github using the integration workflow. Thanks!

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes keyboard event bubbling issues in the SelectPanel component by preventing typeahead keyboard events from propagating outside the component. The fix addresses unwanted behavior where alphabet key presses in the SelectPanel would bubble up to parent components.

  • Extract the isAlphabetKey utility function from useMnemonics hook for reuse
  • Add keyboard event handling to SelectPanel's overlay to prevent event bubbling for typeahead keys
  • Preserve modifier key shortcuts and skip prevention when text inputs are focused

Reviewed Changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.

File Description
packages/react/src/hooks/useMnemonics.ts Exports isAlphabetKey utility function for shared use
packages/react/src/SelectPanel/SelectPanel.tsx Adds keyboard event handler to prevent bubbling of typeahead events

@github-actions github-actions bot requested a deployment to storybook-preview-6900 September 23, 2025 20:12 Abandoned
@github-actions github-actions bot temporarily deployed to storybook-preview-6900 September 23, 2025 20:27 Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-6900 September 23, 2025 20:35 Inactive
@github-actions github-actions bot added integration-tests: failing Changes in this PR cause breaking changes in gh/gh and removed integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm labels Sep 23, 2025
@github-actions github-actions bot added integration-tests: passing Changes in this PR do NOT cause breaking changes in gh/gh and removed integration-tests: failing Changes in this PR cause breaking changes in gh/gh labels Sep 23, 2025
@primer-integration
Copy link

👋 Hi from github/github-ui! Your integration PR is ready: https://github.com/github/github-ui/pull/3155

@primer-integration
Copy link

🟢 ci completed with status success.

Copy link
Member

@TylerJDev TylerJDev left a comment

Choose a reason for hiding this comment

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

LGTM! Left a comment, but otherwise good!

}
: {}),
} as React.CSSProperties,
onKeyDown: preventBubbling(overlayProps?.onKeyDown),
Copy link
Member

Choose a reason for hiding this comment

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

Should we feature flag this to only exist if the primer_react_select_panel_remove_active_descendant flag is activated?

Copy link
Member Author

Choose a reason for hiding this comment

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

We definitely can, I thought you said this was reproducible without it though so I thought it my be beneficial to keep it in regardless? 👀

Copy link
Member

Choose a reason for hiding this comment

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

To be honest, it would let us test it a bit more when staffshipped alongside the FF. I don't anticipate there being any issues with preventing events from bubbling, but I'm curious if anything would come up 🤔

customOnKeyDown?.(event)

const activeElement = document.activeElement as HTMLElement
if (activeElement.tagName === 'INPUT' || activeElement.tagName === 'TEXTAREA') return
Copy link
Member

Choose a reason for hiding this comment

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

❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integration-tests: passing Changes in this PR do NOT cause breaking changes in gh/gh staff Author is a staff member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants