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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Vxee opened this issue May 20, 2024 · 5 comments
Assignees
Labels
component: select This is the name of the generic UI component, not the React module! package: material-ui Specific to @mui/material status: waiting for maintainer These issues haven't been looked at yet by a maintainer

Comments

@Vxee
Copy link

Vxee commented May 20, 2024

Steps to reproduce

Link to live example: (required)
https://codesandbox.io/p/sandbox/stupefied-morse-sh6kcj

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

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 Vxee added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label May 20, 2024
@zannager zannager added component: select This is the name of the generic UI component, not the React module! package: material-ui Specific to @mui/material labels May 20, 2024
@Vxee
Copy link
Author

Vxee commented May 27, 2024

@mj12albert Can you help to check it? Thanks.

@ZeeshanTamboli
Copy link
Member

ZeeshanTamboli commented May 30, 2024

@Vxee I am not able to see the issue in the CodeSandbox you provided. Can you update it?

@ZeeshanTamboli ZeeshanTamboli added status: waiting for author Issue with insufficient information and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels May 30, 2024
@Vxee
Copy link
Author

Vxee commented May 31, 2024

@ZeeshanTamboli @mj12albert I updated CodeSandbox, you can try it, thanks.

@github-actions github-actions bot added status: waiting for maintainer These issues haven't been looked at yet by a maintainer and removed status: waiting for author Issue with insufficient information labels May 31, 2024
@ZeeshanTamboli
Copy link
Member

ZeeshanTamboli commented May 31, 2024

I updated CodeSandbox, you can try it, thanks.

@Vxee Still not seeing the reproduction in the CodeSandbox. You just added a new image in the issue description.

@ZeeshanTamboli ZeeshanTamboli added status: waiting for author Issue with insufficient information and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels May 31, 2024
@Vxee
Copy link
Author

Vxee commented Jun 3, 2024

@ZeeshanTamboli Updated link, please try again. Sorry for that.

@github-actions github-actions bot added status: waiting for maintainer These issues haven't been looked at yet by a maintainer and removed status: waiting for author Issue with insufficient information labels Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: select This is the name of the generic UI component, not the React module! package: material-ui Specific to @mui/material status: waiting for maintainer These issues haven't been looked at yet by a maintainer
Projects
None yet
Development

No branches or pull requests

4 participants