Material: mdNoFloat: Allow value of false to negate

Created on 31 May 2016  路  6Comments  路  Source: angular/material

Actual behavior:

  • When an contains the attribute directive 'md-no-float', and a placeholder attribute is present on the child element, the floating label feature is disabled, in favor of a static label above the input box with no animation.
  • What is the expected behavior?
    I am working on a white-label product where implementations can customize this floating text to be enabled or disabled. if md-no-float='false', it should be the same as having no 'md-no-float' element at all. All other values, including no value, should function as it does today.

Steps to reproduce the issue: *
- Details:
1. Angular material project with a text field input.
2. Add md-no-float='false' as an attribute to the <md-input-container>
3. Make sure the child <input> element has a placeholder="any value" attribute.

Angular Versions: *

  • Angular Version: 1.5.3
  • Angular Material Version: 1.1.0-rc4

Additional Information:

  • Browser Type: All
  • Browser Version: All
  • OS: All

Proposed Fix
In src/components/input/input.js line 579, replace the 'hasNoFloat' evaluation with the following:

    var hasNoFloat = angular.isDefined(inputContainer.element.attr('md-no-float'));
    if(hasNoFloat){
      //Honor md-no-float='false'
      hasNoFloat = (inputContainer.element.attr('md-no-float') != 'false');
    };

I have tried this in my fork here - https://github.com/Sodman/material/blob/no-float-false/src/components/input/input.js and I can confirm it's working. I can create a PR if necessary.

Pull Request

Most helpful comment

The PR is now reopened.

All 6 comments

@daniel-nagy This should be covered in #7961?

Looks like you're right! That PR accomplishes this perfectly. I must have missed it when I searched, my bad.

@DevVersion I believe it should

Yes but now that PR got closed "as part of our 鈥楽urge Focus on Material 2' efforts"...

That's very frustrating, as we're now left with the choice of running on a fork with this fix or dropping angular material entirely, as we can't use it without this feature.

Is there a process to reopen in the future, or is this now a "won't fix"?

The PR is now reopened.

Was this page helpful?
0 / 5 - 0 ratings