material icon indicating copy to clipboard operation
material copied to clipboard

multiple md-select overflows incorrectly the input-container

Open dohomi opened this issue 10 years ago • 25 comments

Hello

there is an issue if the selected values of md-selectexpand md-input-container. Here the codepen and a screenshot:

http://codepen.io/anon/pen/LGGNoo

screen shot 2015-12-15 at 11 28 17

I suggest the md-selectshould grow with the selected options and expand the md-input-containerheight.

dohomi avatar Dec 15 '15 10:12 dohomi

@rschmukler Not sure if this is the best solution, but here is a quick fix/workaround for this issue:

.md-select-value *:first-child {
  width: calc(100% - 24px);
}

I don't see anything in the spec about how to handle this situation, but it looks like we're already assuming that we will cut it off and use an ellipsis, it just wasn't working correctly.

topherfangio avatar Dec 16 '15 17:12 topherfangio

:+1:

Masadow avatar Dec 18 '15 13:12 Masadow

:+1:

nicgirault avatar Jan 09 '16 10:01 nicgirault

+1

bostondv avatar Jan 18 '16 14:01 bostondv

I've noticed this bug as well. It seems to be working fine on version 0.10.x but not on versions 0.11.x and on Version 10: http://plnkr.co/edit/T1UzWlWY8aaMWrM9xPWb?p=preview There's also a version 0.11 there that was added locally so you can switch to see the bug on version 0.11. Here's a live example with 1.0.2: http://plnkr.co/edit/hTBqUnFQQekNEy5YUVc5?p=preview

YonatanKra avatar Jan 19 '16 12:01 YonatanKra

+1

pasqLisena avatar Jan 19 '16 15:01 pasqLisena

I found this workaround: http://codepen.io/anon/pen/MKzYNY Just fix styles: .md-select-value *:first-child { flex: 1 1 auto; }

anatolii-zolotar avatar Feb 08 '16 11:02 anatolii-zolotar

@anatolyz did you try your workaround inside of Firefox? For me the workaround only works with Chrome.

dohomi avatar Feb 09 '16 02:02 dohomi

@dohomi, I checked in versions 41.0.1, 43.0.1, 44.0.1 (updated twice), it works.

anatolii-zolotar avatar Feb 09 '16 08:02 anatolii-zolotar

It would be great if the overflow was hidden. It would be even better if you could change the display to show something like "5 of 25 selected"

norfolkislander avatar Feb 22 '16 05:02 norfolkislander

This issue is closed as part of our deprecation effort. For details, see our post Spring Cleaning 2016.

ThomasBurleson avatar Apr 28 '16 19:04 ThomasBurleson

how is this closed?

bobwah avatar May 24 '16 15:05 bobwah

@bobwah https://github.com/angular/material/issues/6312#issuecomment-215541062 can't you read ?

EmmanuelPREVOST avatar May 24 '16 15:05 EmmanuelPREVOST

I can read it was deprecated when could have been fixed with simple css within material rather than having to apply our own...

bobwah avatar May 24 '16 15:05 bobwah

If you check out the newest version of material you will see that the handling changed: now every option is wrapped into a new line

dohomi avatar May 25 '16 01:05 dohomi

With Angular Material 1.1.1 this behaviour changed again. Instead of putting the selected option on separate lines they are now aligned next to each other again. This causing the select to get a growing width after selecting more options. Is there a way to fix this? See screenshot screen shot 2016-09-19 at 11 27 00 screen shot 2016-09-19 at 11 27 45

Would be nice if you can set a fixed width and the line of selected options would be truncated.

volmerf avatar Sep 19 '16 09:09 volmerf

@volmerf The md-select is designed like most HTML elements to grow and shrink based on the size of it's content. If yours is too large, you have a few options:

  1. Set a max-width in the CSS as I've done here: http://codepen.io/topherfangio/pen/amLbEo
  2. Just set the width in the CSS, or
  3. Use flex to make it take up a certain size in it's container.

All three of these will ensure that the text is truncated when there is too much to fit.

Are you facing a situation where one of the three options above won't work?

topherfangio avatar Sep 30 '16 19:09 topherfangio

@topherfangio : Nice suggestion. You saved my time.

anilkhichar avatar Oct 05 '16 20:10 anilkhichar

Are you facing a situation where one of the three options above won't work?

Yes, this seems to be broken. Sure, if I put flex="30" on my <md-input> it will keep the contained <md-select> from growing more than 30% of the width of my $mdDialog, even though I keep selecting items in the list:

<div layout="row" layout-xs="column" layout-padding>
  <md-input-container flex="30">
    <label>Foo</label>
      <md-select ng-model="dialog.foo" ng-model-options="{trackBy: '$value.id'}" multiple>

But here's the huge problem: if I keep selecting items in the list, soon the $mdDialog will start increasing its width as if the <md-select> were expanding horizontally!! It's as if I've prevented the visible part from expanding, but something invisible is still expanding horiontally. Specifically the <div layout="row" is still expanding, taking up the full space, and making the dialog grow wider, even though the <md-select> is still at its 30%-of-the-width size.

This still happens if I take out the <md-input-container> and <label>, and put the flex="30" directory on the <md-select> --- the <div> still increases its width as if the <md-select> were invisibly getting wider. But it's not --- I can even put text to the right of the <md-select> and the text never moves, but the <div> gets wider!

garretwilson avatar Feb 09 '17 22:02 garretwilson

@garretwilson Can you provide a Codepen that I can play with and maybe fix?

topherfangio avatar Feb 10 '17 21:02 topherfangio