Giter Site home page Giter Site logo

Comments (6)

gengns avatar gengns commented on May 22, 2024 1

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

from shoelace.

claviska avatar claviska commented on May 22, 2024

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

from shoelace.

gengns avatar gengns commented on May 22, 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.

from shoelace.

claviska avatar claviska commented on May 22, 2024

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/

from shoelace.

gengns avatar gengns commented on May 22, 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

from shoelace.

claviska avatar claviska commented on May 22, 2024

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

from shoelace.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.