Skip to content

Commit

Permalink
Disables transition on AvatarStack children that are added after init…
Browse files Browse the repository at this point in the history
…ial render (#3709)

* disables transitions on .pc-AvatarItem when disableExpand is passed

* adds changeset
  • Loading branch information
mperrotti authored Sep 6, 2023
1 parent e480a4a commit edc0168
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
7 changes: 7 additions & 0 deletions .changeset/breezy-insects-work.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@primer/react': patch
---

Fixes a bug where children of AvatarStack would still show a transition when the component re-renders with a different number of children. Fixes https://github.com/primer/react/issues/3688

<!-- Changed components: AvatarStack -->
11 changes: 6 additions & 5 deletions src/AvatarStack/AvatarStack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,6 @@ const AvatarStackWrapper = styled.span<StyledAvatarStackWrapperProps>`
box-shadow: 0 0 0 var(--avatar-border-width) ${get('colors.canvas.default')};
position: relative;
overflow: hidden;
transition:
margin 0.2s ease-in-out,
opacity 0.2s ease-in-out,
visibility 0.2s ease-in-out,
box-shadow 0.1s ease-in-out;
&:first-child {
margin-left: 0;
Expand Down Expand Up @@ -142,6 +137,12 @@ const AvatarStackWrapper = styled.span<StyledAvatarStackWrapperProps>`
opacity: 100%;
visibility: visible;
box-shadow: 0 0 0 4px ${get('colors.canvas.default')};
transition:
margin 0.2s ease-in-out,
opacity 0.2s ease-in-out,
visibility 0.2s ease-in-out,
box-shadow 0.1s ease-in-out;
&:first-child {
margin-left: 0;
}
Expand Down
8 changes: 4 additions & 4 deletions src/__tests__/__snapshots__/AvatarStack.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ exports[`Avatar renders consistently 1`] = `
box-shadow: 0 0 0 var(--avatar-border-width) #ffffff;
position: relative;
overflow: hidden;
-webkit-transition: margin 0.2s ease-in-out,opacity 0.2s ease-in-out,visibility 0.2s ease-in-out,box-shadow 0.1s ease-in-out;
transition: margin 0.2s ease-in-out,opacity 0.2s ease-in-out,visibility 0.2s ease-in-out,box-shadow 0.1s ease-in-out;
}
.c0 .pc-AvatarItem:first-child {
Expand Down Expand Up @@ -125,6 +123,8 @@ exports[`Avatar renders consistently 1`] = `
opacity: 100%;
visibility: visible;
box-shadow: 0 0 0 4px #ffffff;
-webkit-transition: margin 0.2s ease-in-out,opacity 0.2s ease-in-out,visibility 0.2s ease-in-out,box-shadow 0.1s ease-in-out;
transition: margin 0.2s ease-in-out,opacity 0.2s ease-in-out,visibility 0.2s ease-in-out,box-shadow 0.1s ease-in-out;
}
.c0 .pc-AvatarStackBody:not(.pc-AvatarStack--disableExpand):hover .pc-AvatarItem:first-child {
Expand Down Expand Up @@ -197,8 +197,6 @@ exports[`Avatar respects alignRight props 1`] = `
box-shadow: 0 0 0 var(--avatar-border-width) #ffffff;
position: relative;
overflow: hidden;
-webkit-transition: margin 0.2s ease-in-out,opacity 0.2s ease-in-out,visibility 0.2s ease-in-out,box-shadow 0.1s ease-in-out;
transition: margin 0.2s ease-in-out,opacity 0.2s ease-in-out,visibility 0.2s ease-in-out,box-shadow 0.1s ease-in-out;
}
.c0 .pc-AvatarItem:first-child {
Expand Down Expand Up @@ -287,6 +285,8 @@ exports[`Avatar respects alignRight props 1`] = `
opacity: 100%;
visibility: visible;
box-shadow: 0 0 0 4px #ffffff;
-webkit-transition: margin 0.2s ease-in-out,opacity 0.2s ease-in-out,visibility 0.2s ease-in-out,box-shadow 0.1s ease-in-out;
transition: margin 0.2s ease-in-out,opacity 0.2s ease-in-out,visibility 0.2s ease-in-out,box-shadow 0.1s ease-in-out;
}
.c0 .pc-AvatarStackBody:not(.pc-AvatarStack--disableExpand):hover .pc-AvatarItem:first-child {
Expand Down

0 comments on commit edc0168

Please sign in to comment.