-
Notifications
You must be signed in to change notification settings - Fork 609
Wrap AvatarStack
avatars in isolation: isolate
to create a new stacking context
#5705
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
Conversation
🦋 Changeset detectedLatest commit: 03da629 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
👋 Hi, this pull request contains changes to the source code that github/github depends on. If you are GitHub staff, we recommend testing these changes with github/github using the integration workflow. Thanks! |
size-limit report 📦
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, TIL about stacking contexts 😎 Any way to write tests for this?
I have another branch I'm working on that uses |
Here's my alternative: #5714 It's not as straightforward as this solution, but it has some nice benefits. I'll leave it up to the reviewers to decide which direction we want to go. |
…acking context (#5705) * Wrap `AvatarStack` avatars in `isolation: isolate` * Create strange-pets-stare.md * Snap!
The stacking order of the avatars inside
AvatarStack
is controlled viaz-index
because it is reversed from the DOM order (earlier items display on top). This works fine within the component, but the effects ofz-index
can easily leak outside the component and cause unexpected bugs wherever any other component overlaysAvatarStack
. An example of this is https://github.com/github/copilot-productivity/issues/3985 (internal issue link) where the avatars appear on top of a dialog that should cover them.The stacking order here only matters relative to the other avatars within the same component, so we can easily prevent this type of bug by isolating the
z-index
effects via a new stacking context. The most explicit way to create a new stacking context is via theisolation
property:This PR simply adds
isolation: isolate
to theAvatarStack
container.There is prior art for this approach in
ButtonGroup
; see #2910.As a followup, it might be worth considering an audit of all uses of
z-index
within Primer to ensure they are properly isolated. In fact I would even consider an ESLint rule banning the use ofz-index
so that we have to explicitly override the rule and thus verify that we have considered the side effects + stacking context.Changelog
New
Changed
Fixed stacking bugs relating to
AvatarStack
.Removed
Rollout strategy
Testing & Reviewing
Merge checklist