md-textfloat: Inaccessible <input> element #547
Description
When the developer uses md-textfloat, he/she doesn't have access to the input itself in the template.
What does that mean? It means that things like this won't work as expected:
<md-textfloat ng-blur="doSomethingOnBlur()"></md-textfloat>
This is because the ngBlur
directive is listening for the blur
event on the md-textfloat
container element, not the inner input
element itself. This will be the same for the input
, focus
, etc events.
Then there are input attributes that won't work:
<md-textfloat autocapitalize="off"></md-textfloat>
The developer will expect this to put the autocapitalize="off"
attribute on the input, and stop auto-capitalization on mobile. But again, this attribute will stay on the container.
There are potentially hundreds of directives and attributes that could be put on the <md-textfloat>
container that the developer will expect to be passed straight to the <input>
. We can't manually cover them all.
Fixing This
The best way to fix this would be to use replace: true
on the md-textfloat directive, then set the template to be an <input>
. This would cause all of the attributes to be passed to a real native <input>
.
Then we could use DOM magic to place the <label>
element as a sibling, and remove the label when the input is removed.