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(textfield): Convert some foundation methods from private to public #1543

Merged
merged 7 commits into from
Nov 8, 2017
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 13 additions & 19 deletions packages/mdc-textfield/foundation.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,17 @@ class MDCTextfieldFoundation extends MDCFoundation {
/** @private {boolean} */
this.useCustomValidityChecking_ = false;
/** @private {function(): undefined} */
this.inputFocusHandler_ = () => this.activateFocus_();
this.inputFocusHandler_ = () => this.activateFocus();
/** @private {function(): undefined} */
this.inputBlurHandler_ = () => this.deactivateFocus_();
this.inputBlurHandler_ = () => this.deactivateFocus();
/** @private {function(): undefined} */
this.inputInputHandler_ = () => this.autoCompleteFocus_();
this.inputInputHandler_ = () => this.autoCompleteFocus();
/** @private {function(!Event): undefined} */
this.setPointerXOffset_ = (evt) => this.setBottomLineTransformOrigin_(evt);
this.setPointerXOffset_ = (evt) => this.setBottomLineTransformOrigin(evt);
/** @private {function(!Event): undefined} */
this.textFieldInteractionHandler_ = (evt) => this.handleTextFieldInteraction_(evt);
this.textFieldInteractionHandler_ = (evt) => this.handleTextFieldInteraction(evt);
/** @private {function(!Event): undefined} */
this.transitionEndHandler_ = (evt) => this.transitionEnd_(evt);
this.transitionEndHandler_ = (evt) => this.transitionEnd(evt);
}

init() {
Expand Down Expand Up @@ -129,9 +129,8 @@ class MDCTextfieldFoundation extends MDCFoundation {
/**
* Handles all user interactions with the Textfield.
* @param {!Event} evt
* @private
*/
handleTextFieldInteraction_(evt) {
handleTextFieldInteraction(evt) {
if (this.adapter_.getNativeInput().disabled) {
return;
}
Expand All @@ -150,9 +149,8 @@ class MDCTextfieldFoundation extends MDCFoundation {

/**
* Activates the text field focus state.
* @private
*/
activateFocus_() {
activateFocus() {
const {BOTTOM_LINE_ACTIVE, FOCUSED, LABEL_FLOAT_ABOVE, LABEL_SHAKE} = MDCTextfieldFoundation.cssClasses;
this.adapter_.addClass(FOCUSED);
this.adapter_.addClassToBottomLine(BOTTOM_LINE_ACTIVE);
Expand All @@ -166,9 +164,8 @@ class MDCTextfieldFoundation extends MDCFoundation {
* Sets the transform-origin of the bottom line, causing it to animate out
* from the user's click location.
* @param {!Event} evt
* @private
*/
setBottomLineTransformOrigin_(evt) {
setBottomLineTransformOrigin(evt) {
const targetClientRect = evt.target.getBoundingClientRect();
const evtCoords = {x: evt.clientX, y: evt.clientY};
const normalizedX = evtCoords.x - targetClientRect.left;
Expand All @@ -181,11 +178,10 @@ class MDCTextfieldFoundation extends MDCFoundation {
/**
* Activates the Textfield's focus state in cases when the input value
* changes without user input (e.g. programatically).
* @private
*/
autoCompleteFocus_() {
autoCompleteFocus() {
if (!this.receivedUserInput_) {
this.activateFocus_();
this.activateFocus();
}
}

Expand All @@ -202,9 +198,8 @@ class MDCTextfieldFoundation extends MDCFoundation {
* Fires when animation transition ends, performing actions that must wait
* for animations to finish.
* @param {!Event} evt
* @private
*/
transitionEnd_(evt) {
transitionEnd(evt) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm kind of surprised that we'd be publicizing this method in particular... would there be a better name for this that would give better context to when it'd make sense to directly invoke it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Gave this and setBottomLineTransformOrigin more semantic names.

const {BOTTOM_LINE_ACTIVE} = MDCTextfieldFoundation.cssClasses;

// We need to wait for the bottom line to be entirely transparent
Expand All @@ -217,9 +212,8 @@ class MDCTextfieldFoundation extends MDCFoundation {

/**
* Deactives the Textfield's focus state.
* @private
*/
deactivateFocus_() {
deactivateFocus() {
const {FOCUSED, LABEL_FLOAT_ABOVE, LABEL_SHAKE} = MDCTextfieldFoundation.cssClasses;
const input = this.getNativeInput_();

Expand Down