Skip to content
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

feat(text-field): Support for types- color, date, datetime-local, etc #2854

Merged
merged 15 commits into from
Jul 31, 2018
Merged

Conversation

namannehra
Copy link
Contributor

@namannehra namannehra commented May 31, 2018

Label will always float for the following types as they show some UI even if value is empty

  • color
  • date
  • datetime-local
  • month
  • range
  • time
  • week

Added getType and setType methods to foundation. setType must be used to update type after initialisation.

@namannehra
Copy link
Contributor Author

Is this fine? Do I need fix something or make any changes?

@williamernest williamernest self-assigned this Jun 5, 2018
@@ -49,9 +48,15 @@ class MDCTextFieldFoundation extends MDCFoundation {
return !this.isValid() && !this.isFocused_;
}

/** @return {boolean} */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change to @private and update the name to shouldAlwaysFloat_.

  /**
   * @return {boolean}
   * @private
   */
  get shouldAlwaysFloat_() {
    const type = this.getNativeInput_().type;
    return ALWAYS_FLOAT_TYPES.indexOf(type) >= 0;
  }

  /** @return {boolean} */
  get shouldFloat() {
    return this.shouldAlwaysFloat_ || this.isFocused_ || !!this.getValue() || this.isBadInput_();
  }

/**
* @param {string} type The type to set on the input Element.
*/
setType(type) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dynamically changing type isn't a common use case. This should be removed.

/**
* @return {string} The type of the input Element.
*/
getType() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be removed.

@namannehra
Copy link
Contributor Author

namannehra commented Jun 10, 2018

@williamernest Sorry for the late response. I have made the changes you suggested.

@codecov-io
Copy link

codecov-io commented Jul 30, 2018

Codecov Report

Merging #2854 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2854      +/-   ##
==========================================
+ Coverage   98.36%   98.36%   +<.01%     
==========================================
  Files         120      120              
  Lines        5123     5125       +2     
  Branches      638      637       -1     
==========================================
+ Hits         5039     5041       +2     
  Misses         84       84
Impacted Files Coverage Δ
packages/mdc-textfield/foundation.js 98.94% <100%> (ø) ⬆️
packages/mdc-textfield/constants.js 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cd36b2e...f832b07. Read the comment docs.

Copy link
Contributor

@williamernest williamernest left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@williamernest williamernest merged commit 0d02f1f into material-components:master Jul 31, 2018
@williamernest
Copy link
Contributor

@namannehra Sorry for the delay. Thanks for fixing this for us!

@jamesmfriedman jamesmfriedman mentioned this pull request Aug 23, 2018
48 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants