react icon indicating copy to clipboard operation
react copied to clipboard

fix(Portal): blur activeElement children when unmounting

Open joshblack opened this issue 1 year ago • 3 comments

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

  • [x] 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 avatar Apr 04 '24 21:04 joshblack

🦋 Changeset detected

Latest commit: a2f794061a604f97d661446f1eb9c5491a669535

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

changeset-bot[bot] avatar Apr 04 '24 21:04 changeset-bot[bot]

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% 🔽)

github-actions[bot] avatar Apr 04 '24 21:04 github-actions[bot]

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.

joshblack avatar Apr 23 '24 17:04 joshblack

Hi! This pull request has been marked as stale because it has been open with no activity for 60 days. You can comment on the pull request or remove the stale label to keep it open. If you do nothing, this pull request will be closed in 7 days.

github-actions[bot] avatar Jun 22 '24 18:06 github-actions[bot]