Skip to content

fix: keep nested details clicks inside the outer disclosure - #8760

Open
nemo-crypto wants to merge 1 commit into
primer:mainfrom
nemo-crypto:fix/details-nested-interactions
Open

nemo-crypto wants to merge 1 commit into
primer:mainfrom
nemo-crypto:fix/details-nested-interactions

Conversation

@nemo-crypto

Copy link
Copy Markdown

With useDetails({defaultOpen: true, closeOnOutsideClick: true}), clicking a button inside a nested <details> invokes the outer onClickOutside handler and closes the outer disclosure. The handler compares the nearest <details> with its own ref, so nested content is incorrectly classified as outside.

Use DOM containment to determine whether the click is inside the controlled details element. Actual outside clicks still close it, and an outside-click callback can still prevent closing.

Changelog

New

  • Regression coverage for nested content, nested toggling, actual outside clicks, and cancellation of outside-click dismissal.

Changed

  • useDetails keeps the outer disclosure open when users interact with nested details content.
  • Add a patch changeset for @primer/react.

Removed

  • None.

Rollout strategy

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

Testing & Reviewing

  • The nested-content regression fails before the fix because onClickOutside is called for the inner button.
  • All 12 Details tests pass with the fix in Chromium.
  • Full suite: 3,096 passed, 3 skipped, 10 todo; the existing deprecated DialogV1 Escape/focus test timed out. Its isolated suite rerun passed all 9 tests (the same full-suite timeout was observed before this branch).
  • npm run build, npm run type-check, npm run lint:fix, npm run lint:css, and npm run format:diff pass.

Prepared with AI assistance; the regression and fix were verified locally.

@nemo-crypto
nemo-crypto requested a review from a team as a code owner November 16, 2026 01:48
@changeset-bot

changeset-bot Bot commented Nov 16, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 475b87c

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

This branch has not been deployed

No deployments
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