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

ensure scroll position does not change when opening actionmenu #2411

Merged

Conversation

keithamus
Copy link
Member

@keithamus keithamus commented Nov 30, 2023

What are you trying to accomplish?

Sometimes opening the actionmenu causes the page to jump to the top, due to subtle timing issues with the anchored element positioning itself; it starts at the top of the page and only positions itself when visible. The actionmenu focusses the first element and if the menu hasn't had time to position itself, the page will jump. This fixes that.

Integration

No

List the issues that this change affects.

Closes https://github.com/github/primer/issues/2897, https://github.com/github/primer/issues/2900

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 moved the focus to the toggle event, which is fired after the popover is opened. anchored-position positions the element on a beforetoggle event which is always fired before the element becomes visible, so the position should be correct and the page won't jump.

Anything you want to highlight for special attention from reviewers?

No

Accessibility

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

Merge checklist

  • Added/updated tests
  • 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 30, 2023

🦋 Changeset detected

Latest commit: aef8227

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

@keithamus keithamus force-pushed the ensure-scroll-position-does-not-change-when-opening-actionmenu branch from ff1c1ce to f6747be Compare November 30, 2023 16:27
@github-actions github-actions bot added the javascript Pull requests that update Javascript code label Nov 30, 2023
@keithamus keithamus force-pushed the ensure-scroll-position-does-not-change-when-opening-actionmenu branch from ff4e8f1 to ab503c2 Compare December 1, 2023 11:38
@keithamus keithamus force-pushed the ensure-scroll-position-does-not-change-when-opening-actionmenu branch from 45b4f30 to e2a8241 Compare December 5, 2023 10:38
@keithamus keithamus force-pushed the ensure-scroll-position-does-not-change-when-opening-actionmenu branch from e2a8241 to 89f5601 Compare December 5, 2023 10:38
@keithamus keithamus force-pushed the ensure-scroll-position-does-not-change-when-opening-actionmenu branch from 89f5601 to 0027574 Compare December 5, 2023 10:42

This comment was marked as outdated.

By using the `toggle` event we can ensure the popover is open and
positioned (positioning happens during `beforetoggle`) before trying to
focus the element.
@keithamus keithamus force-pushed the ensure-scroll-position-does-not-change-when-opening-actionmenu branch from 0ead775 to f6a8725 Compare December 5, 2023 12:32
@keithamus keithamus marked this pull request as ready for review December 8, 2023 10:03
@keithamus keithamus requested review from a team and camertron December 8, 2023 10:03
@jonrohan
Copy link
Member

Could we have a system test for this?

@github-actions github-actions bot removed the javascript Pull requests that update Javascript code label Dec 14, 2023
@jonrohan jonrohan merged commit 58e700a into main Dec 15, 2023
29 of 30 checks passed
@jonrohan jonrohan deleted the ensure-scroll-position-does-not-change-when-opening-actionmenu branch December 15, 2023 18:48
@primer primer bot mentioned this pull request Dec 15, 2023
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.

3 participants