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

[Popper] Allow setting default props in a theme #30118

Merged
merged 4 commits into from
Mar 9, 2022
Merged

[Popper] Allow setting default props in a theme #30118

merged 4 commits into from
Mar 9, 2022

Conversation

hafley66
Copy link
Contributor

@hafley66 hafley66 commented Dec 8, 2021

I realize now that its very difficult to add defaultProps for Portal, as its used by both modal and popper in base, so it wont inherit the default props.

It came as a surprise that its not possible to default the props for Portal, but I think everything either uses Modal/Popper/or Popover, which all have Portal props passed, so this would add ability to pass defaultProps to the Popper component and allow deeper defaulting

Closes #30116

Will not solve the portal issue, but I believe Popper is last component to not have defaultProps for container, so this will still cover the rest of the Portal'd elements.

@hafley66 hafley66 changed the title [POC] Initial idea of allowing default props to Portal [POC] Initial idea of allowing default props to Popper in mui/material Dec 8, 2021
@hafley66
Copy link
Contributor Author

hafley66 commented Dec 8, 2021

@DanailH @m4theushw Is this a feasible PR/approach?

@mui-pr-bot
Copy link

mui-pr-bot commented Dec 8, 2021

Details of bundle changes

Generated by 🚫 dangerJS against 1827a46

@danilo-leal danilo-leal changed the title [POC] Initial idea of allowing default props to Popper in mui/material [POC][Popper] Initial idea of allowing default props to Popper in @mui/material Dec 8, 2021
@danilo-leal danilo-leal added component: Popper The React component. See <Popup> for the latest version. new feature New feature or request labels Dec 8, 2021
@michaldudak
Copy link
Member

Thanks for your contribution. Your implementation seems to be working well. Could you, however, add a test to verify it?

Does this resolve #30116?

@michaldudak michaldudak added the PR: needs test The pull request can't be merged label Dec 15, 2021
@michaldudak michaldudak changed the title [POC][Popper] Initial idea of allowing default props to Popper in @mui/material [Popper] Allow setting default props in a theme Dec 15, 2021
@siriwatknp
Copy link
Member

👋 The migration PR has been merged.

Please follow these steps to make sure that the contents are all updated. (Sorry for the inconvenience)

  1. pull latest master from upstream to your branch
  2. if your PR has changes on the *.md or demo files, you are likely to encounter conflict because all of them have been moved to the new folder.
    2.1 revert the change on those markdown files you did
    2.2 pull latest master from upstream (you should not see conflict)
    2.3 make the changes again at docs/data/material/*
  3. run yarn docs:api
    • you might see the changes in docs/pages/material/api/* if your PR touches some of the components
    • it is okay if there is no changes

If you are struggle with the steps above, feel free to tag @siriwatknp

@kanoshin
Copy link
Contributor

kanoshin commented Feb 18, 2022

@hafley66 just a friendly ping. I faced the same issue you have with Shadow DOM. Do you have time to add the unit test @michaldudak requested? I think he wants to have a test similar to the one Modal component has https://github.com/mui/material-ui/blob/master/packages/mui-material/src/Modal/Modal.test.js#L57.

@hafley66
Copy link
Contributor Author

Unfortunately, I have too many reasons to remove shadow dom (it is breaking selenium tests that are expecting iframes), so I can no longer spend time on this. Plus, recent changes in data grid are why I needed this, and there are other ways to solve Popper props there too

@mui-bot
Copy link

mui-bot commented Mar 9, 2022

Details of bundle changes

Generated by 🚫 dangerJS against 9547027

@michaldudak michaldudak removed the PR: needs test The pull request can't be merged label Mar 9, 2022
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.

I added the test. Everything seems to be working well.
Thanks for the implementation!

@michaldudak michaldudak merged commit d15c8b5 into mui:master Mar 9, 2022
Copy link
Member

@oliviertassinari oliviertassinari left a comment

Choose a reason for hiding this comment

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

We need to update https://mui.com/components/popper/. This is no longer true:

Screenshot 2022-03-15 at 02 00 05

https://bundlephobia.com/package/@mui/[email protected]

Screenshot 2022-03-15 at 02 03 13

https://bundlephobia.com/package/@mui/[email protected]

Screenshot 2022-03-15 at 02 03 46

For those that only care about the change, they can still use https://bundlephobia.com/package/@mui/[email protected]

Screenshot 2022-03-15 at 02 04 12

So I think that we can update https://mui.com/components/popper/#unstyled too to mention the bundle size.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: Popper The React component. See <Popup> for the latest version. new feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Portal] Add ThemeOptions.components.MuiPortal.defaultProps
8 participants