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

'sl-select multiple' shrinks and doesn't show full options #1811

Closed
gengns opened this issue Jan 10, 2024 · 6 comments
Closed

'sl-select multiple' shrinks and doesn't show full options #1811

gengns opened this issue Jan 10, 2024 · 6 comments
Labels
bug Things that aren't working right in the library.

Comments

@gengns
Copy link

gengns commented Jan 10, 2024

Describe the bug

Every sl-select has a default width that makes possible to see its options. However, when you set the multiple attribute you lose the default width.

To Reproduce

Click on selects provided in Demo.

Demo

https://jsfiddle.net/2j43kfh6/

Screenshots

image
image

@gengns gengns added the bug Things that aren't working right in the library. label Jan 10, 2024
@claviska
Copy link
Member

The control is designed so the listbox is the same width as the "text field" that displays the selection. In most cases, this is desirable. In your case, the control is so small you can't even see the label.

If you really want controls that small, you can change the size of the listbox with CSS. However, users will still have trouble viewing the selected items. 🤷🏻‍♂️

sl-select::part(listbox) {
  min-width: min-content; 
  white-space: nowrap;
}

Result:

CleanShot 2024-01-11 at 13 55 09@2x

@gengns
Copy link
Author

gengns commented Jan 11, 2024

Dear @claviska, thank you so much for your answer, but I'm not changing any size in any sl-select. Select 1 and Select 2 are the default examples from the Shoelace documentation.

<div style="display: flex">
  <sl-select label="Select 1" multiple clearable>
    <sl-option value="option-1">Option 1</sl-option>
    <sl-option value="option-2">Option 2</sl-option>
  </sl-select>

  <sl-select label="Select 2" clearable>
    <sl-option value="option-1">Option 1</sl-option>
    <sl-option value="option-2">Option 2</sl-option>
  </sl-select>
</div>

If you remove the value from the sl-select with the multiple attribute, it doesn't work as expected. We cannot see options : (

<sl-select label="Select 1" multiple clearable>

If you remove the value from the sl-select without the multiple attribute, it works as expected.

<sl-select label="Select 2" clearable>

Example here.

Sorry If if I didn't explain myself well enough before, I don't know, maybe I'm missing something.

Thank you so much for your time.

@claviska
Copy link
Member

The display: flex container is causing the sizing issue. If you need it as a flex child, either set an explicit width or an appropriate flex.

https://jsfiddle.net/oL2u581q/

@gengns
Copy link
Author

gengns commented Jan 14, 2024

But why it's needed extra CSS or change component just for sl-select with the multiple attribute. Is that behavior made on propose for something? I'm using FF and Chromium based browsers.

With normal sl-select you don't need to change / add anything, it simple works.
https://jsfiddle.net/fuk3p9nv/1/

image

@claviska
Copy link
Member

Because you’re overriding the default display (and thus size) by putting it into a flex container.

@gengns
Copy link
Author

gengns commented Jan 14, 2024

@claviska but both sl-select and sl-select multiple should behave the same inside the flex container and they are not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Things that aren't working right in the library.
Projects
None yet
Development

No branches or pull requests

2 participants