Skip to content

perf(hooks): stabilize Escape and outside-click callbacks - #8562

Draft
joshblack wants to merge 1 commit into
joshblack/react-compiler-hooksfrom
joshblack/react-compiler-stable-callbacks
Draft

joshblack wants to merge 1 commit into
joshblack/react-compiler-hooksfrom
joshblack/react-compiler-stable-callbacks

Conversation

@joshblack

Copy link
Copy Markdown
Member

Follow up to #8558.

This PR updates useOnEscapePress and useOnOutsideClick to use our existing effect-synchronized callback helper. Callback changes no longer re-register their event handlers or reattach the document listener.

The public APIs stay the same, including explicit callback dependencies passed to useOnEscapePress. This is preparation for its compiler migration; useOnEscapePress remains excluded while we preserve that dependency-array contract.

Changelog

New

Changed

  • Update Escape and outside-click handlers to keep event subscriptions stable when callbacks change.
  • Update Escape handler IDs to use lazy state initialization, matching outside-click handlers.

Removed

Rollout strategy

This is a patch performance improvement with no public API changes.

  • No changes needed in github/github-ui
  • Needs changes in github/github-ui
  • Ships with feature flag(s)
  • Not sure
  • None

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: e632d4e3-54d2-4423-9888-8e37b00494a3
@joshblack
joshblack added this pull request to stack #8559 October 16, 2026 15:55
@changeset-bot

changeset-bot Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 01ac8b5

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

@github-actions github-actions Bot added staff Author is a staff member integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm labels Oct 16, 2026
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Action required

👋 Hi, this pull request contains changes to the source code that github/github-ui depends on. If you are GitHub staff, test these changes with github/github-ui using the integration workflow. Check the integration testing docs for step-by-step instructions. Or, apply the integration-tests: skipped manually label to skip these checks.

Comment thread packages/react/src/hooks/useOnEscapePress.ts
Comment thread .changeset/stable-event-hook-callbacks.md
@primer-integration

primer-integration Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Integration test results from github/github-ui PR:

Waiting  Changes   Waiting
Passed  CI   Passed
Waiting  VRT   Waiting
Running  Projects   Running

This branch was successfully deployed

2 active deployments
storybook-preview-8562 — 01ac8b51 Deployed Oct 16, 2026 by github-actions[bot]
github-pages — 01ac8b51 Deployed Oct 16, 2026 by joshblack via deploy-preview #33737
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm staff Author is a staff member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant