angularangular-materialangular-material2

Disable float for mdInput text field


In an Angular 4 (Material) app, I have a text field for search. When I type in the field, a second field appears showing the entered text. This new field floats as I scroll the page. How do I disable the floating behavior?

It doesn't seem to be default behavior for a text field. I've tried md-no-float, but that's for the placeholder text I understand. Someone suggested setting an empty value, so I added that, but the problem remains.

<md-input-container md-no-float style="width: 100%">
      <input mdInput formControlName="search" value="" placeholder="Search Terms" />
</md-input-container>

Solution

  • It turns out it's the Chrome autocomplete popping up.

    If you add autocomplete="off" to both the form and the input field, it will go away.