-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
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
[AvatarGroup] Enable targeting of additional Avatar when max props is passed #30794
Conversation
Hey, I see the failed tests but Im not sure what to make of them. It looks like they're originating from material-next. Did I miss a step somewhere? |
These tests tend to fail randomly every now and then. We haven't found why yet. |
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.
Please change the wording in two places and it should be good to go.
@@ -15,6 +17,14 @@ export interface AvatarGroupProps extends StandardProps<React.HTMLAttributes<HTM | |||
* Override or extend the styles applied to the component. | |||
*/ | |||
classes?: Partial<AvatarGroupClasses>; | |||
/** | |||
* The props used for targeting the additional avatar when max prop is set. |
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.
componentsProps
is more generic. You can use a description similar to ones found in other components, such as:
/**
* The props used for each slot inside the AvatarGroup.
* @default {}
*/
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.
done
@@ -49,6 +49,22 @@ describe('<AvatarGroup />', () => { | |||
expect(container.textContent).to.equal('+2'); | |||
}); | |||
|
|||
it('should allow for props on additionalAvatar', () => { |
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.
it('should allow for props on additionalAvatar', () => { | |
it('should pass props from componentsProps.additionalAvatar to the slot component', () => { |
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.
and done!
@@ -127,6 +128,7 @@ const AvatarGroup = React.forwardRef(function AvatarGroup(inProps, ref) { | |||
marginLeft, | |||
}} | |||
variant={variant} | |||
{...componentsProps.additionalAvatar} |
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.
One thing I noticed during testing is that the provided componentsProps override the existing className.
We should merge the class names instead. Same goes for the style
prop:
<AvatarGroupAvatar
ownerState={ownerState}
variant={variant}
{...componentsProps.additionalAvatar}
className={clsx(classes.avatar, componentsProps.additionalAvatar?.className)}
style={{ marginLeft, ...componentsProps.additionalAvatar?.style }}
>
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.
that makes sense
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.
All good! Thanks for your work!
My particular problem was that I needed to change the size of the additional avatar that comes up with a max prop. This worked in V4 but there was a code change for V5 that rendered that
Avatar
as a first child.link to original issue