material-ui
material-ui copied to clipboard
[material-ui] Select components contain too many menu items with scroll, the padding right attribute is set not correctly
Steps to reproduce
Link to live example: (required) https://codesandbox.io/p/sandbox/determined-agnesi-ymllnq?file=%2Fsrc%2FDemo.tsx
I override global Menu and MenuItem component style
Steps:
- Click select component
- hover or select one
- The paddingRight is '0', it should be '8px'
Current behavior
Expected behavior
Context
I have checked the Select code, here is the logic will add this logic to override the padding
React.useImperativeHandle(
actions,
() => ({
adjustStyleForScrollbar: (containerElement, { direction }) => {
// Let's ignore that piece of logic if users are already overriding the width
// of the menu.
const noExplicitWidth = !listRef.current.style.width;
if (containerElement.clientHeight < listRef.current.clientHeight && noExplicitWidth) {
const scrollbarSize = `${getScrollbarSize(ownerDocument(containerElement))}px`;
listRef.current.style[direction === 'rtl' ? 'paddingLeft' : 'paddingRight'] =
scrollbarSize;
listRef.current.style.width = `calc(100% + ${scrollbarSize})`;
}
return listRef.current;
},
}),
[],
);
Is it possible provide a prop can turn off this function?
Your environment
npx @mui/envinfo
Don't forget to mention which browser you used.
Output from `npx @mui/envinfo` goes here.
Search keywords: Select, Menu, scroll, padding-right