-
-
Notifications
You must be signed in to change notification settings - Fork 32k
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
[Popover] Add ownerState
on the paper slot
#34445
Conversation
I just have some trouble with the label at the CI, if that is something that I need to do to correct this, just let me know. |
ownerState
on the paper slot
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.
The fix looks good. Let's add a test for it (in Popover.test.js
):
index e9e0d21116..465503305e 100644
--- a/packages/mui-material/src/Popover/Popover.test.js
+++ b/packages/mui-material/src/Popover/Popover.test.js
@@ -7,6 +7,7 @@ import Grow from '@mui/material/Grow';
import Modal from '@mui/material/Modal';
import Paper from '@mui/material/Paper';
import Popover, { popoverClasses as classes } from '@mui/material/Popover';
+import { ThemeProvider, createTheme } from '@mui/material/styles';
import { getOffsetLeft, getOffsetTop } from './Popover';
import useForkRef from '../utils/useForkRef';
@@ -877,4 +878,26 @@ describe('<Popover />', () => {
expect(screen.getByTestId('transition')).not.to.have.attribute('data-timeout');
});
});
+
+ it("should not throw if ownerState is used in slot's styleOverrides", () => {
+ expect(() =>
+ render(
+ <ThemeProvider
+ theme={createTheme({
+ components: {
+ MuiPopover: {
+ styleOverrides: {
+ paper: ({ ownerState }) => ({
+ marginTop: ownerState.transformOrigin?.vertical === 'top' ? '4px' : 0,
+ }),
+ },
+ },
+ },
+ })}
+ >
+ <Popover anchorEl={document.createElement('div')} open><div /></Popover>
+ </ThemeProvider>,
+ ),
+ ).not.to.throw();
+ });
});
The test basically ensures that accessing ownerState
in the style overrides for the paper in the Popover
, won't throw.
Done, if you need anything else, please, let me know. |
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.
Looks good, thanks for the contribution!
This PR fixes #34404
As explained in issue #34404,
ownerState
was missing in Popover.