md-autocomplete: md-no-float support
Would it be possible to support md-no-float attribute when using md-autocomplete with md-floating-label option ? So the autocomplete integrates great with other inputs in forms, and we have the option to make it "placeholder only".
+1
+1
+1
CSS workaround to selectively hide the label and keep correct alignment with other md-no-float elements (based on the workaround by @lkaragol):
md-autocomplete.no-label > md-autocomplete-wrap > md-input-container > label {
display: none;
}
Then apply the class no-label to the autocomplete in question.
It would be really nice to have an official solution to this that preserves placeholder labels.
I have seen that solution but the issue still exists because I need a placeholder.
Indeed
Here's a workaround that actually shows the labels, with a couple of caveats: (We couldn't wait)
// Workaround lack of md-autocomplete: md-no-float support: https://github.com/angular/material/issues/3219.
// Apply no-float class to md-autocomplete with md-floating-label. Drawbacks:
// - Clears label when focused, not just when has-value, to avoid clearing the scaling
// - Font weight appears stronger than for input placeholders
// - It's a hack
md-autocomplete.no-float > md-autocomplete-wrap > md-input-container {
> label {
transform: none;
transition-property: none;
color: #BDBDBD; // input placeholder gray
position: absolute;
top: 10px;
}
&.md-input-focused > label {
color: transparent;
}
&.md-input-has-value > label {
color: transparent;
}
}
+1 would be great!
@bluebirdtech, your workaround is awesome, thanks for sharing! Unfortunately it broke for me in RC7, so I hope they get to this not long after 1.0 is released.
@mattdanna Thanks for the update - I haven't updated for a while so didn't spot that. If this hasn't been fixed when I next take an update I'll see if there's a workaround for the workaround. ;)
Just updated to 1.0.5. The updated workaround is shorter and produces better results, as the placeholder remains visible when the input has focus.
// Workaround lack of md-autocomplete: md-no-float support: https://github.com/angular/material/issues/3219.
// Apply no-float class to md-autocomplete with md-floating-label.
md-autocomplete.no-float > md-autocomplete-wrap > md-input-container {
margin-top: 0px;
> label {
-webkit-transform: translate3d(1px,28px,0) scale(1) !important;
transform: translate3d(1px,28px,0) scale(1) !important;
color: #BDBDBD; // input placeholder gray
}
&.md-input-has-value > label {
display: none !important;
}
}
+1