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(Portal): blur activeElement children when unmounting #4469

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

joshblack
Copy link
Member

Context https://github.com/github/issues/issues/10142

Update our Portal behavior to check for an activeElement and, if it has one, blur the element. This seems to help address a timing issue where we are removing a portal and focusing an element like in the linked issue.

Specifically, in Safari it seems that even though we restore focus that it doesn't restore the page position without going through this.

Changelog

New

Changed

  • Update Portal to blur activeElement children when removing an element

Removed

Rollout strategy

  • Patch release

Testing & Reviewing

  • Visit the default SelectPanel storybook
  • Add enough content on the page to cause it to scroll
  • Observe that dismissing the SelectPanel with escape does not cause the page to scroll

@joshblack joshblack requested a review from a team as a code owner April 4, 2024 21:33
Copy link

changeset-bot bot commented Apr 4, 2024

🦋 Changeset detected

Latest commit: a2f7940

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

Copy link
Contributor

github-actions bot commented Apr 4, 2024

size-limit report 📦

Path Size
packages/react/dist/browser.esm.js 88.01 KB (-0.03% 🔽)
packages/react/dist/browser.umd.js 88.34 KB (-0.03% 🔽)

Copy link
Contributor

@siddharthkp siddharthkp left a comment

Choose a reason for hiding this comment

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

Good digging!

This feels like a hack but a very nicely self-contained hack, so happy to ship it if it fixes a bug for us

Let's test this with dotcom to make sure there are no regressions (maybe a good candidate to discuss staff shipping)

@joshblack
Copy link
Member Author

Following up, this fails downstream tests suite typically with an act() violation error 🤔 So it may be that this change is causing effects to happen where they do not typically in these downstream tests and they need act() to remedy it.

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.

None yet

2 participants