Skip to content
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

Merged
merged 6 commits into from
Feb 1, 2022

Conversation

mogrady88
Copy link
Contributor

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

@mui-bot
Copy link

mui-bot commented Jan 26, 2022

Details of bundle changes

Generated by 🚫 dangerJS against 0a94dc4

@mogrady88
Copy link
Contributor Author

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?

@mnajdova mnajdova requested a review from michaldudak January 27, 2022 08:01
@michaldudak
Copy link
Member

These tests tend to fail randomly every now and then. We haven't found why yet.
I restarted the CI task. Let's see if anything gets better.

Copy link
Member

@michaldudak michaldudak left a 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.
Copy link
Member

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 {}
  */

Copy link
Contributor Author

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', () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
it('should allow for props on additionalAvatar', () => {
it('should pass props from componentsProps.additionalAvatar to the slot component', () => {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and done!

@danilo-leal danilo-leal added the component: avatar This is the name of the generic UI component, not the React module! label Jan 27, 2022
@@ -127,6 +128,7 @@ const AvatarGroup = React.forwardRef(function AvatarGroup(inProps, ref) {
marginLeft,
}}
variant={variant}
{...componentsProps.additionalAvatar}
Copy link
Member

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 }}
>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that makes sense

Copy link
Member

@michaldudak michaldudak left a 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!

@michaldudak michaldudak merged commit 239cc27 into mui:master Feb 1, 2022
@oliviertassinari oliviertassinari added the new feature New feature or request label Feb 1, 2022
wladimirguerra pushed a commit to wladimirguerra/material-ui that referenced this pull request Feb 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: avatar This is the name of the generic UI component, not the React module! new feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants