ui icon indicating copy to clipboard operation
ui copied to clipboard

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

Open franzwilhelm opened this issue 10 months ago • 1 comments

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

  • [X] I've made research efforts and searched the documentation
  • [X] I've searched for existing issues

franzwilhelm avatar Apr 22 '24 11:04 franzwilhelm

+1

kevinlandsberg avatar May 07 '24 13:05 kevinlandsberg

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

tomo-kn avatar May 30 '24 13:05 tomo-kn