material icon indicating copy to clipboard operation
material copied to clipboard

Angular Material md-select multiple align horizontally

Open getglad opened this issue 10 years ago • 3 comments

Actual behavior:

  • What is the issue? * When I select my multiple options, in the view my options stack vertically.
  • What is the expected behavior? I would like to list them horizontally. So instead of:
    AR,
    CA

I would get:

AR, CA

CodePen or Steps to reproduce the issue: *

  • CodePen Demo which shows your issue :
  • Details:

Angular Template:

    <div layout="row"
      <md-input-container class="md-block" flex-gt-sm>
        <label>Pick State</label>
        <md-select multiple flex ng-model="main.selectedData.State">
          <md-option ng-repeat="(key, value) in main.State" value="{{value.value}}">
            {{value.display}}
          </md-option>
        </md-select>
      </md-input-container>
    </div>

Rendered HTML:

    <md-select-value class="md-select-value" id="select_value_label_1">
      <span>
        <div class="md-container">
          <div class="md-icon"></div>
        </div>
        <div class="md-text ng-binding">
            AR
        </div>
        ,
        <div class="md-container">
          <div class="md-icon"></div>
        </div>
        <div class="md-text ng-binding">
            CA
        </div>
      </span>
      <span class="md-select-icon" aria-hidden="true"></span>
    </md-select-value>

Screenshot: vertical states

Angular Versions: *

  • Angular Version: 1.5.6
  • Angular Material Version: 1.0.9

Additional Information:

  • Browser Type: * Chrome and IE 11
  • Browser Version: * Chrome Version 51.0.2704.84 m (64-bit); IE Version 11.0.9600.18314
  • OS: * Win 7
  • Stack Traces:

Shortcut to create a new CodePen Demo. Note: * indicates required information. Without this information, your issue may be auto-closed.

Do not modify the titles or questions. Simply add your responses to the ends of the questions. Add more lines if needed.

getglad avatar Jun 10 '16 17:06 getglad

My suggestion would be to wrap the injected comma in a div as well so everything can just float left

getglad avatar Jun 10 '16 17:06 getglad

This was my workaround. I would do a pull request but I upgraded to nodejs 6 and I am not able to compile angular-material.

md-select[multiple] { ._md-container { display: inline-block; } }

It would be useful to provide the separator as an optional element defaulting to comma for those who want to do custom styling of the md-text div.

henrymana avatar Jun 10 '16 18:06 henrymana

Any update on this? The original ask is still not resolved:- When I select my multiple options, in the view my options stack vertically.I would like to list them horizontally.

I see one workaround by modifying css - http://stackoverflow.com/questions/37754408/angular-material-md-select-multiple-align-horizontally but this should be provided as part od md-select directive.

rohitrule avatar Aug 15 '16 07:08 rohitrule