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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Menu] ownerState is undefined when the Menu is opened #34404

Closed
2 tasks done
takakobem opened this issue Sep 21, 2022 · 4 comments 路 Fixed by #34445
Closed
2 tasks done

[Menu] ownerState is undefined when the Menu is opened #34404

takakobem opened this issue Sep 21, 2022 · 4 comments 路 Fixed by #34445
Labels
bug 馃悰 Something doesn't work component: menu This is the name of the generic UI component, not the React module! good first issue Great for first contributions. Enable to learn the contribution process. package: material-ui Specific to @mui/material

Comments

@takakobem
Copy link
Contributor

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Steps to reproduce 馃暪

You can check here. When you click DASHBOARD button and error occurs.
https://codesandbox.io/s/amazing-dubinsky-pkesu9?file=/index.js

Current behavior 馃槸

TypeError occurs.

paper
/index.js:20:31
  17 | styleOverrides: {
  18 |   paper: ({ ownerState }) => ({
  19 |     marginTop:
> 20 |       ownerState.anchorOrigin?.vertical === "bottom" &&
     |                 ^
  21 |       ownerState.transformOrigin?.vertical === "top"
  22 |         ? "4px"
  23 |         : 0

Expected behavior 馃

no error occurs and can access ownerState.

Context 馃敠

I created custom theme for MuiMenu to change the style.

Your environment 馃寧

CodeSandbox

@takakobem takakobem added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Sep 21, 2022
@siriwatknp siriwatknp added bug 馃悰 Something doesn't work component: menu This is the name of the generic UI component, not the React module! package: material-ui Specific to @mui/material and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Sep 22, 2022
@siriwatknp
Copy link
Member

ownerState is missing in Popover.

diff --git a/packages/mui-material/src/Popover/Popover.js b/packages/mui-material/src/Popover/Popover.js
index f35d551f64..15812e8ede 100644
--- a/packages/mui-material/src/Popover/Popover.js
+++ b/packages/mui-material/src/Popover/Popover.js
@@ -374,6 +374,7 @@ const Popover = React.forwardRef(function Popover(inProps, ref) {
           {...PaperProps}
           ref={handlePaperRef}
           className={clsx(classes.paper, PaperProps.className)}
+          ownerState={ownerState}
         >
           {children}
         </PopoverPaper>

@siriwatknp siriwatknp added the good first issue Great for first contributions. Enable to learn the contribution process. label Sep 22, 2022
@kabernardes
Copy link
Contributor

kabernardes commented Sep 23, 2022

Hi, can I try this one?

@siriwatknp
Copy link
Member

Hi, can I try this one?

Absolutely!

@mnajdova
Copy link
Member

This is an important thing that should be resolved in v6. I remembered we had a discussion around it in #31982.

It's the third time we are seeing similar issue.

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: menu This is the name of the generic UI component, not the React module! good first issue Great for first contributions. Enable to learn the contribution process. package: material-ui Specific to @mui/material
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants