material-ui icon indicating copy to clipboard operation
material-ui copied to clipboard

[material-ui] Select components contain too many menu items with scroll, the padding right attribute is set not correctly

Open Vxee opened this issue 1 year ago • 0 comments

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:

  1. Click select component
  2. hover or select one
  3. The paddingRight is '0', it should be '8px'

Current behavior

image

Expected behavior

image

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

Vxee avatar May 20 '24 08:05 Vxee