Skip to content

fix(popover): close popover when trigger scrolls out of view#3982

Open
ArkadiNazarian wants to merge 2 commits into
radix-ui:mainfrom
ArkadiNazarian:fix/popover-close-when-trigger-hidden
Open

fix(popover): close popover when trigger scrolls out of view#3982
ArkadiNazarian wants to merge 2 commits into
radix-ui:mainfrom
ArkadiNazarian:fix/popover-close-when-trigger-hidden

Conversation

@ArkadiNazarian

Copy link
Copy Markdown

Closes: #3688

Problem
When a Popover is opened inside a scrollable container and the user scrolls, the Popover content overflows its parent container and remains visible even after the trigger element has been scrolled out of view.

Solution
This PR adds logic to automatically close the Popover when its trigger element scrolls out of the visible viewport. This prevents the Popover from appearing detached from its trigger and overflowing the parent container.

Storybook Example
Added a new Storybook story demonstrating the fix:

Story name: Popover / In Scroll Container

Location: apps/storybook/stories/popover.stories.tsx

Tests

  1. Unit Tests (packages/react/popover/src/popover.test.tsx):
  • Tests hideWhenDetached prop defaults to true

  • Tests ability to override hideWhenDetached to false

  1. E2E Tests (cypress/e2e/Popover.cy.ts):
  • Tests Popover closes when trigger scrolls out of view in a scrollable container

@changeset-bot

changeset-bot Bot commented Jun 30, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 7a9c3ff

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

This PR includes changesets to release 10 packages
Name Type
@radix-ui/react-popover Minor
@radix-ui/react-popper Minor
radix-ui Patch
@radix-ui/react-hover-card Patch
@radix-ui/react-menu Patch
@radix-ui/react-select Patch
@radix-ui/react-tooltip Patch
@radix-ui/react-context-menu Patch
@radix-ui/react-dropdown-menu Patch
@radix-ui/react-menubar 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

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.

Popover inside scrollable container overflows parent

1 participant