ember-power-select icon indicating copy to clipboard operation
ember-power-select copied to clipboard

Implement a matchContentWidth option to "inherit width of longest option"

Open mansona opened this issue 7 years ago • 5 comments
trafficstars

This is mostly an issue to keep track of a feature request that @cibernox mentioned here: https://github.com/cibernox/ember-power-select/issues/301#issuecomment-182027192

I would love this feature 👍

mansona avatar Dec 04 '17 12:12 mansona

I tried to use use both of the suggested options (matchTriggerWidth and renderInPlace) and it does not work either:

# templates/application.hbs
<nav class="navbar-nav mx-auto">
  {{shop-select
    shops=shopService.shops
    aShop=currentShop.shop
    returnToDashBoard=(action "redirectToDashboard")
    matchTriggerWidth=false
    renderInPlace=true
  }}
</nav>

The drop-down list always takes the the width of the selected item length. Any ideas ? Thank you.

belgoros avatar Jan 14 '19 15:01 belgoros

@belgoros I believe that there is a missunderstanding. What matchTriggerWidth and renderInPlace can be used to is to make the list of options to be as width as needed, but I have the hunch that what you want is to make the trigger (the part that is visible even when closed) to be as width as the longest option.

If that is the case, that is virtually impossible. There is no way to know how long the longest option will be without rendering it first.

cibernox avatar Jan 14 '19 22:01 cibernox

@cibernox Thank you for the feedback. Nope, what I want is to make the list of options to be as wider as needed, based on the very longest list item in the list. For example, I have the following HTML select input:

<select>
            <option value="volvo">Volvo</option>
            <option value="saab">Saab</option>
            <option value="mercedes">Mercedes</option>
            <option value="audi">Audi</option>
            <option value="long">VeeeeeeeryLoooooooooooongVeeehicle</option>
</select>

In this scenario, when using ember-power-select, the width of the select input actually depends on the length of the selected item instead of the the length of the very longest one. Is it possible ? Thank you.

belgoros avatar Jan 15 '19 08:01 belgoros

Still waiting on this - "matchContentWidth" would be a much-appreciated feature.

AddisonG avatar Dec 12 '19 02:12 AddisonG

@AddisonG it's complicated. It would require to render things once, measure which one is the longest option and then resize the container again. Probably that should happen offscreen to avoid flickering. Its a complicated feature and probably outside of core, but I'm happy to assist if anyone wants to pursue it.

cibernox avatar Dec 13 '19 18:12 cibernox