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 ActionMenu position issue when container is scrollable #3207

Merged
merged 2 commits into from
Dec 5, 2024

Conversation

camertron
Copy link
Contributor

@camertron camertron commented Nov 22, 2024

What are you trying to accomplish?

This PR fixes a bug in ActionMenu that causes the menu not to travel with the invoker button when scrolling inside a container that scrolls independent of the body, eg. with a constrained height and overflow: auto.

Screenshots

Before

Alt: An ActionMenu is opened and the page scrolled. The menu stays fixed in its original position as the page scrolls up and down. The menu is closed and re-opened, which temporarily attaches the menu to the button.

before.mov

After

Alt: An ActionMenu is opened and the page scrolled. The menu remains attached to the button as the page scrolls up and down.

after.mov

Integration

No changes necessary in production.

List the issues that this change affects.

Fixes #3175

Risk Assessment

  • Low risk the change is small, highly observable, and easily rolled back.
  • Medium risk changes that are isolated, reduced in scope or could impact few users. The change will not impact library availability.
  • High risk changes are those that could impact customers and SLOs, low or no test coverage, low observability, or slow to rollback.

What approach did you choose and why?

I adopted a technique we used in SelectPanel which is based on ActionMenu) that updates the <anchored-position> element whenever the page scrolls. This is a bit tricky because attaching a scroll event listener to window is not enough here, since the scrolling element is actually the container instead of the page body. I was able to get things to work by capturing the scroll event.

Accessibility

  • No new axe scan violation - This change does not introduce any new axe scan violations.

Merge checklist

- [ ] Added/updated tests (I don't think there's a reliable way to test this)
- [ ] Added/updated documentation

  • Added/updated previews (Lookbook)
  • Tested in Chrome
  • Tested in Firefox
  • Tested in Safari
  • Tested in Edge

Take a look at the What we look for in reviews section of the contributing guidelines for more information on how we review PRs.

Copy link

changeset-bot bot commented Nov 22, 2024

🦋 Changeset detected

Latest commit: 84a0c1a

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

This PR includes changesets to release 1 package
Name Type
@primer/view-components 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

@camertron camertron marked this pull request as ready for review November 25, 2024 17:35
@camertron camertron requested a review from a team as a code owner November 25, 2024 17:35
@camertron camertron requested review from francinelucca and jonrohan and removed request for francinelucca November 25, 2024 17:35
Copy link
Member

@jonrohan jonrohan left a comment

Choose a reason for hiding this comment

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

Changes work as expected in lookbook, I'm going to merge and test in the release to see if there's any regressions.

@jonrohan jonrohan merged commit 5880922 into main Dec 5, 2024
34 checks passed
@jonrohan jonrohan deleted the fix_action_menu_scrolling_behavior branch December 5, 2024 20:36
@primer primer bot mentioned this pull request Dec 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Opened ActionMenu does not scroll with anything other than body
2 participants