shadcn-ui / ui

Beautifully designed components that you can copy and paste into your apps. Accessible. Customizable. Open Source.
https://ui.shadcn.com
MIT License
74.4k stars 4.59k forks source link

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

Open franzwilhelm opened 6 months ago

franzwilhelm commented 6 months ago

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

kevinlandsberg commented 6 months ago

+1

tomo-kn commented 5 months ago

https://github.com/shadcn-ui/ui/pull/3868