fix(Portal): blur activeElement children when unmounting
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
Portalto 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
🦋 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
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% 🔽) |
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.
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.