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

[Accordion] Fix IconButtonProps spreading logic #21850

Merged
merged 5 commits into from
Jul 20, 2020
Merged

[Accordion] Fix IconButtonProps spreading logic #21850

merged 5 commits into from
Jul 20, 2020

Conversation

kgregory
Copy link
Member

@kgregory kgregory commented Jul 20, 2020

The expanded class was being replaced when IconButtonProps was provided with a className. To fix this, we revisit the application of className to IconButton. We will continue to conditionally apply expanded, but now we'll combine it with className from IconButtonProps, which now defaults to an empty object.

Added onBlur test to improve coverage of this component.

Regenerated docs.

Closes #21744

@mui-pr-bot
Copy link

mui-pr-bot commented Jul 20, 2020

Details of bundle changes

Generated by 🚫 dangerJS against 4c08676

@oliviertassinari oliviertassinari added the component: accordion This is the name of the generic UI component, not the React module! label Jul 20, 2020
@oliviertassinari oliviertassinari changed the title [AccordionSummary] Add expanded class when IconButtonProps are provided [Accordion] Fix IconButtonProps spreading logic Jul 20, 2020
@oliviertassinari oliviertassinari added the bug 🐛 Something doesn't work label Jul 20, 2020
Copy link
Member

@eps1lon eps1lon left a comment

Choose a reason for hiding this comment

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

Actual fix looks good. One minor regarding unrelated changes.

@@ -99,6 +111,17 @@ describe('<AccordionSummary />', () => {
expect(button).not.to.have.class(classes.focused);
});

it('should fire onBlur when the button blurs', () => {
Copy link
Member

Choose a reason for hiding this comment

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

That one requires act.

Copy link
Member

Choose a reason for hiding this comment

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

I don't understand why it's green in my env

Copy link
Member

Choose a reason for hiding this comment

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

Ohhh, it's because I'm running the tests in watch mode! I still haven't got used to mochajs/mocha#4347.

Copy link
Member Author

Choose a reason for hiding this comment

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

It passes, but I think the idea is that we're asserting on the result of the field receiving focus and blurring and we want to ensure that the updates are completed prior to assertion.

There are a few other places in the codebase that are inconsistent about this, so I didn't wrap it here (e.g. Select.test.js, , but I probably should have. Sorry about that.

@eps1lon what is the difference between this (in blur should unset unfocused state):

    act(() => {
      button.focus();
    });
    act(() => {
      button.blur();
    });

...and wrapping them with one act? Is it that we're allowing focus to update before we blur?

kgregory and others added 5 commits July 20, 2020 17:39
…ops are provided

Ensure that `expanded` and `IconButtonProps.className` are applied.

Added `onBlur` test to improve coverage of this component.
@oliviertassinari oliviertassinari merged commit b676ea7 into mui:next Jul 20, 2020
@oliviertassinari
Copy link
Member

@kgregory Thanks, it's great to not only fix the bug in question but to actually be a good boy-scout, leaving the place in better shape than when entering.

@kgregory
Copy link
Member Author

@oliviertassinari thanks. Sorry about missing that act. I won't make that mistake again.

@oliviertassinari
Copy link
Member

oliviertassinari commented Jul 20, 2020

@kgregory I think that it's simply because your fork next branch is from an old version (~20 days), your build was green before I rebased it. Try pulling the latest changes :)

@kgregory
Copy link
Member Author

@oliviertassinari oh that's embarrassing. Will do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: accordion This is the name of the generic UI component, not the React module!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Accordion] className merge issue with IconButtonProps
4 participants