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

[base-ui][Select] Buggy absolute input triggers body scrollbar #40565

Closed
OpenSource03 opened this issue Jan 13, 2024 · 2 comments · Fixed by #40599
Closed

[base-ui][Select] Buggy absolute input triggers body scrollbar #40565

OpenSource03 opened this issue Jan 13, 2024 · 2 comments · Fixed by #40599
Labels
bug 🐛 Something doesn't work component: select This is the name of the generic UI component, not the React module! package: base-ui Specific to @mui/base regression A bug, but worse

Comments

@OpenSource03
Copy link

OpenSource03 commented Jan 13, 2024

Steps to reproduce

Link to live example: (click here)

Steps:

  1. Install BaseUI (NextJS)
  2. Create Select element
  3. You should see a scrollbar appear

Current behavior

Screenshot 2024-01-13 at 18 54 03

The scrollbar appears, due to an input element being created along with Select. The input element has position absolute and margin -1, which causes the issue to happen.

Expected behavior

No body scrollbar

Context

No response

Your environment

npx @mui/envinfo
  BrowserUsed: Arc and Chrome
  System:
    OS: macOS 14.3
  Binaries:
    Node: 18.19.0 - ~/.nvm/versions/node/v18.19.0/bin/node
    npm: 10.2.3 - ~/.nvm/versions/node/v18.19.0/bin/npm
    pnpm: Not Found
  Browsers:
    Chrome: 120.0.6099.216
    Edge: Not Found
    Safari: 17.3
  npmPackages:
    @emotion/styled: ^11.11.0 => 11.11.0 
    @mui/base: ^5.0.0-beta.31 => 5.0.0-beta.31 
    @mui/core-downloads-tracker:  5.15.3 
    @mui/icons-material: ^5.15.3 => 5.15.3 
    @mui/material: ^5.15.3 => 5.15.3 
    @mui/private-theming:  5.15.3 
    @mui/styled-engine:  5.15.3 
    @mui/styled-engine-sc: ^6.0.0-alpha.12 => 6.0.0-alpha.12 
    @mui/system: ^5.15.3 => 5.15.3 
    @mui/types:  7.2.12 
    @mui/utils:  5.15.3 
    @types/react: ^18 => 18.2.46 
    react: ^18 => 18.2.0 
    react-dom: ^18 => 18.2.0 
    styled-components: ^6.1.6 => 6.1.6 
    typescript: ^5 => 5.3.3 

Search keywords: select, margin

@OpenSource03 OpenSource03 added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Jan 13, 2024
@OpenSource03 OpenSource03 changed the title BaseUI BaseSelect adds an absolute input with -1 margin, which shows scrollbar BaseUI BaseSelect adds an absolute input with -1 margin, which triggers the scrollbar to show Jan 13, 2024
@oliviertassinari
Copy link
Member

oliviertassinari commented Jan 14, 2024

To reproduce, very simple: go to https://mui.com/base-ui/react-select/#introduction, and voilà:

If you are not seeing it, please, enable https://www.notion.so/mui-org/Laptop-configuration-d306ca6120004d2e9034144e71c45b34?pvs=4#2bd404c6337443a0870ba1238293a457 as a permanent setting on macOS.

It's a regression introduced in #38167, so I think it should be the same people who take care of this bug to optimize context.

Also, it's strange, why is are the source of the Base UI select

const visuallyHiddenStyle: React.CSSProperties = {
clip: 'rect(1px, 1px, 1px, 1px)',
clipPath: 'inset(50%)',
height: '1px',
width: '1px',
margin: '-1px',
overflow: 'hidden',
padding: 0,
position: 'absolute',
left: '50%',
bottom: 0, // to display the native browser validation error at the bottom of the Select.
};

inline the style of the visuallyHidden helper?

const visuallyHidden: import('react').CSSProperties = {
border: 0,
clip: 'rect(0 0 0 0)',
height: '1px',
margin: -1,
overflow: 'hidden',
padding: 0,
position: 'absolute',
whiteSpace: 'nowrap',
width: '1px',
};

It looks like bundle-size bloat to me. It would also solve this bug.

@oliviertassinari oliviertassinari added component: select This is the name of the generic UI component, not the React module! package: base-ui Specific to @mui/base bug 🐛 Something doesn't work regression A bug, but worse labels Jan 14, 2024
@oliviertassinari oliviertassinari changed the title BaseUI BaseSelect adds an absolute input with -1 margin, which triggers the scrollbar to show [base-ui][Select] Buggy absolute input triggers body scrollbar Jan 15, 2024
brijeshb42 added a commit to brijeshb42/material-ui that referenced this issue Jan 15, 2024
brijeshb42 added a commit to brijeshb42/material-ui that referenced this issue Jan 15, 2024
brijeshb42 added a commit to brijeshb42/material-ui that referenced this issue Jan 15, 2024
@oliviertassinari
Copy link
Member

oliviertassinari commented Jan 16, 2024

Off-topic

We have two ways to improve here:

  1. @zannager There is no need to assign Albert. Brijsh had already opened a PR, so if someone should have been assigned, it's Brijesh. See above:

Screenshot 2024-01-16 at 01 39 53

  1. @brijeshb42 But then, since Brijesh opened a PR, I think you should have removed the "status: waiting for maintainer" label (I didn't because I don't want to create a dependency on me, I left a comment as if I was a random contributor). This would have cleared it from @zannager view https://www.notion.so/mui-org/GitHub-community-issues-PRs-Tier-1-12a84fdf50e44595afc55343dac00fca as an issue that needs to be handled.

@brijeshb42 brijeshb42 removed the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Jan 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: select This is the name of the generic UI component, not the React module! package: base-ui Specific to @mui/base regression A bug, but worse
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants