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

[bug]: Overflow on select portal viewport when select items are too wide #3575

Open
2 tasks done
franzwilhelm opened this issue Apr 22, 2024 · 1 comment
Open
2 tasks done
Labels
bug Something isn't working

Comments

@franzwilhelm
Copy link

franzwilhelm commented Apr 22, 2024

Describe the bug

This can even be reproduced on the shadcn website:
image

When not enough screen real estate

The select trigger wraps as expected. The portal doesn't

image

When enough screen real estate

Everything works as expected

image

Affected component/components

select

How to reproduce

This snippet will cause overflow with the default select implementation

    <Select>
      <SelectTrigger>
        <SelectValue placeholder="Placeholder" />
      </SelectTrigger>
      <SelectContent>
        <SelectGroup>
          <SelectItem value="test">
            Sint eiusmod nostrud nostrud elit do eu. Exercitation aliquip nisi velit commodo
            exercitation qui ut anim. Magna nulla voluptate velit anim. Est eiusmod veniam nostrud
            reprehenderit velit tempor labore exercitation magna labore exercitation anim pariatur
            occaecat. Id duis exercitation id esse est esse sit nulla reprehenderit. Ipsum quis duis
            duis exercitation eiusmod excepteur velit.
          </SelectItem>
        </SelectGroup>
      </SelectContent>
    </Select>

Is fixed by changing min-w to max-w here:
image

Another solution might be to use min-w-[var(--radix-select-trigger-width)] max-w-[100vw], to avoid maxing out on select trigger width for small triggers with larger portal viewports

Will submit a PR to fix this shortly

Codesandbox/StackBlitz link

No response

Logs

No response

System Info

Not relevant

Before submitting

  • I've made research efforts and searched the documentation
  • I've searched for existing issues
@franzwilhelm franzwilhelm added the bug Something isn't working label Apr 22, 2024
@kevinlandsberg
Copy link

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants