-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
[Select][material] Fix select menu moving on scroll when disableScrollLock is true #37773
[Select][material] Fix select menu moving on scroll when disableScrollLock is true #37773
Conversation
Netlify deploy previewhttps://deploy-preview-37773--material-ui.netlify.app/ Bundle size reportDetails of bundle changes (Toolpad) |
@michaldudak @gzrae Right now the ci/codesandbox build is failing and I'm not sure why. When I run |
Hi, just wanted to follow up on this question and see if you guys had any thoughts? |
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.
Hey @VishruthR, thanks for working on this! 😊 And sorry for the late response.
I think the solution works 🚀 I added two comments to improve it, let me know what you think
Signed-off-by: Vishruth Raj <[email protected]>
@@ -6,11 +6,10 @@ import Typography from '@mui/joy/Typography'; | |||
const customTheme = extendTheme({ | |||
typography: { | |||
kbd: { | |||
background: | |||
'linear-gradient(to top, var(--joy-palette-background-level2), var(--joy-palette-background-surface))', | |||
backgroundColor: 'var(--joy-palette-background-surface)', |
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.
When I ran yarn docs:typescript:formatted
this file changed
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.
This is related to a Joy UI default theme update: https://github.com/mui/material-ui/pull/36843/files#diff-300d121fc27c24b580132ae34564f8ac77dfb0aeaeaa3dcbcce03c3ff31b7011
Can you try merging the latest master to your branch and see if this change goes away?
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.
Git seems to think my branch is up to date with master so merging does nothing.
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.
Thanks for working on the feedback 😊
A couple more polish comments 🙌🏼
...other | ||
} = props; | ||
|
||
const disableScrollLock = props.disableScrollLock ?? false; |
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.
This can be added to the props destructure:
// ...
disableMarginThreshold = false,
disableScrollLock = false,
...other
We would have to explicitly add it to the Root props as it won't go inside the other
props anymore, so on line 416:
const { slotProps: rootSlotPropsProp, ...rootProps } = useSlotProps({
elementType: RootSlot,
externalSlotProps: slotProps?.root || {},
- externalForwardedProps: other,
+ externalForwardedProps: {
+ disableScrollLock,
+ ...other
+ },
additionalProps: {
ref,
slotProps: { backdrop: { invisible: true } },
container,
open,
},
ownerState,
className: clsx(classes.root, className),
});
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.
It seems like adding this line caused me to fail a unit test. I'm not too sure what this error is saying exactly so any guidance would be great!
1) <Menu />
MUI component API
allows overriding the root slot with an element using the slots.root prop:
Expected test not to call console.error() but instead received 1 calls.
If the warning is expected, test for it explicitly by using the toErrorDev() matcher.
Test location:
/tmp/material-ui/packages/mui-material/src/Menu/Menu.test.js
console.error message #1:
Warning: React does not recognize the `disableScrollLock` prop on a DOM element. If you intentionally want it to appear in the DOM as a custom attribute, spell it as lowercase `disablescrolllock` instead. If you accidentally passed it from a parent component, remove it from the DOM element.
at i
at Popover (/tmp/material-ui/packages/mui-material/src/Popover/Popover.js:4389:71)
at /tmp/material-ui/node_modules/@emotion/react/dist/emotion-element-48d2c2e4.cjs.dev.js:62:23
at Menu (/tmp/material-ui/packages/mui-material/src/Menu/Menu.js:1761:70)
at Wrapper (/tmp/material-ui/test/utils/createRenderer.tsx:403:7)
@@ -6,11 +6,10 @@ import Typography from '@mui/joy/Typography'; | |||
const customTheme = extendTheme({ | |||
typography: { | |||
kbd: { | |||
background: | |||
'linear-gradient(to top, var(--joy-palette-background-level2), var(--joy-palette-background-surface))', | |||
backgroundColor: 'var(--joy-palette-background-surface)', |
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.
This is related to a Joy UI default theme update: https://github.com/mui/material-ui/pull/36843/files#diff-300d121fc27c24b580132ae34564f8ac77dfb0aeaeaa3dcbcce03c3ff31b7011
Can you try merging the latest master to your branch and see if this change goes away?
Here's the original repro codesandbox: https://codesandbox.io/s/bitter-violet-wpfhc4?file=/src/App.js:0-704 Here's the codesandbox showcasing the new functionality by using @michaldudak may I ask a review from you here? |
const positioningStyle = getElementStyleOfOpenPopover(mockedAnchor); | ||
|
||
expect(positioningStyle.top).to.equal(`${marginThreshold}px`); | ||
expect(positioningStyle.left).to.equal(`${marginThreshold}px`); | ||
expect(positioningStyle.transformOrigin).to.match(/0px 1px( 0px)?/); | ||
expect(positioningStyle.transformOrigin).to.match(/0px -1px( 0ms)?/); |
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.
Why 0ms
?
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.
Pretty sure it is a typo 🤔, it's present in master: https://github.com/mui/material-ui/blob/master/packages/mui-material/src/Popover/Popover.test.js#L890
Fixed it
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.
👍
Thank you for fixing this! I'm seeing that on MacOS, the bouncy-scroll does not play well with this. Is there anything that can be done about this? Screen.Recording.2023-08-30.at.7.20.09.PM.mov |
@bnussman-akamai, could you please open a new issue so we can track this problem? |
Solves bug where if a user has a Select component with a MenuList that has disableScrollLock set to true, the MenuList will scroll with the screen.
Demo of bug: https://codesandbox.io/s/bitter-violet-wpfhc4?file=/src/App.js
Closes #37752