Skip to content

Md-Select and Hint #2624

Closed
Closed

Description

@Caloman

Newbie doubts
Md-select does not accept hints and breaks pattern with input or i'm doing it wrong?

Usage in forms compromised!

Activity

  1. codef0rmer commented on Jan 14, 2017

    @codef0rmer

    I know where you are coming from. I usually use md-hint for validation errors which is not ideal BTW. A hacky way would be,

    <md-input-container>
        <input style="display:none" md-input>
        <md-select placeholder="Favorite food" [(ngModel)]="selectedValue" name="food">
            <md-option *ngFor="let food of foods" [value]="food.value">
                {{food.viewValue}}
            </md-option>
        </md-select>
        <md-hint align="end">Select something</md-hint>
    </md-input-container>
    

    P.S. extra CSS is required to hide div.md-input-underline ;-)

  2. added
    feature
    P5
    on Jan 24, 2017
  3. kryzys69 commented on Feb 5, 2017

    @kryzys69

    I thing it would be nice if you can embed md-select and in the future md-datepicker and maybe other components in md-input-container, just like you can in Material 1...

  4. kara commented on Feb 10, 2017

    @kara
    Contributor

    Tracking this in #2498. Closing as a dupe.

  5. tgiddings commented on Mar 24, 2017

    @tgiddings

    @codef0rmer can you elaborate on the css to hide the fake input in your trick? I've tried variations of

    .select-input-container .mat-input-underline{
      display:none;
    }
    

    where select-input-container is a class I add to the input container. Not only does this have no effect on the extra underline, but this rule doesn't even show up in firefox's inspector as being considered for the underline element. you mention a div.md-input-underline, but there is no div in the inspector with that class; the divs' classes all start with the prefix mat-.

  6. antonyboom commented on Mar 31, 2017

    @antonyboom

    @tgiddings finally after couple hours, I figured out how to fix it. here is working code

    style.css

    .tricky-select {
      width: 100%;
    }
    .tricky-select .mat-input-underline {
      display: none;
    }
    
      <md-input-container class="tricky-select">
          <input type="text" mdInput class="form-full-width" [ngStyle]="{'display':'none'}" >
          <md-select placeholder="client" class="form-full-width" [(ngModel)]="dialog.stuff" required name="stuff" #stuff="ngModel" [disabled]="dialog.used">
            <md-option *ngFor="let item of items" [value]="item.id" >
              {{ item.name }}
            </md-option>
          </md-select>
          <md-hint *ngIf="f.submitted && (stuff.untouched || !stuff.valid)" [ngStyle]="{'color': 'red'}" align="end">Field is required</md-hint>
        </md-input-container>
    
  7. gcfabri commented on Apr 1, 2017

    @gcfabri

    @antonyboom I tried this but didn't work... Could you provide a plunk?

  8. antonyboom commented on Apr 3, 2017

    @antonyboom

    @gcfabri I'm sorry cannot reproduce it in plunker because official example doesn't work and I couldn't force to work it. It requires to import BrowserAnimationsModule which is not accessible from cloudflare at this moment

  9. ramshinde92 commented on Jul 6, 2017

    @ramshinde92

    @antonyboom Not working for me either.

  10. jeanpchr commented on Jul 10, 2017

    @jeanpchr

    @gcfabri @ramshinde92
    Place the "tricky" css at the end of your material theme file, that did the "trick" for me.

  11. M3enjamin commented on Jul 17, 2017

    @M3enjamin

    for that css problem, another way is to use /deep/
    like this:
    .tricky-select /deep/ .mat-input-underline {
    display: none;
    }

  12. mackelito commented on Jul 17, 2017

    @mackelito

    What does /deep/ do?

  13. willshowell commented on Jul 17, 2017

    @willshowell
    Contributor

    @mackelito for components that have ViewEncapsulation, it will break through it. For example, with ViewEncapsulation,

    .tricky-select .mat-input-underline { }
    
    // compiles to...
    
    .tricky-select[_ngcontent-c1] .mat-input-underline[_ngcontent-c1] { }
    .tricky-select /deep/ .mat-input-underline { }
    
    // compiles to...
    
    .tricky-select[_ngcontent-c1] .mat-input-underline { }
  14. mackelito commented on Jul 17, 2017

    @mackelito

    Aaah Good to know! What does the "deep" stand for?

  15. willshowell commented on Jul 17, 2017

    @willshowell
    Contributor

    Presumable just the word "deep" for accessing elements that belong to "deeper" components? Note, however, that it is being deprecated. You can read more here https://angular.io/guide/component-styles#deprecated-deep--and-ng-deep

  16. angular-automatic-lock-bot commented on Sep 6, 2019

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  17. locked and limited conversation to collaborators on Sep 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P5feature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions