Skip to content

Md-Select and Hint #2624

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Caloman opened this issue Jan 13, 2017 · 15 comments
Closed

Md-Select and Hint #2624

Caloman opened this issue Jan 13, 2017 · 15 comments
Labels
feature This issue represents a new feature or feature request rather than a bug or bug fix P5 The team acknowledges the request but does not plan to address it, it remains open for discussion

Comments

@Caloman
Copy link

Caloman commented Jan 13, 2017

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

Usage in forms compromised!

@codef0rmer
Copy link

codef0rmer commented Jan 14, 2017

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 ;-)

@kara kara added feature This issue represents a new feature or feature request rather than a bug or bug fix P5 The team acknowledges the request but does not plan to address it, it remains open for discussion labels Jan 24, 2017
@kryzys69
Copy link

kryzys69 commented Feb 5, 2017

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...

@kara
Copy link
Contributor

kara commented Feb 10, 2017

Tracking this in #2498. Closing as a dupe.

@tgiddings
Copy link

@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-.

@antonyboom
Copy link

antonyboom commented Mar 31, 2017

@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>

@gcfabri
Copy link

gcfabri commented Apr 1, 2017

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

@antonyboom
Copy link

@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

@ramshinde92
Copy link

@antonyboom Not working for me either.

@jeanpchr
Copy link

jeanpchr commented Jul 10, 2017

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

@M3enjamin
Copy link

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

@mackelito
Copy link

What does /deep/ do?

@willshowell
Copy link
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 { }

@mackelito
Copy link

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

@willshowell
Copy link
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

@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature This issue represents a new feature or feature request rather than a bug or bug fix P5 The team acknowledges the request but does not plan to address it, it remains open for discussion
Projects
None yet
Development

No branches or pull requests