Skip to content
This repository was archived by the owner on Jan 13, 2025. It is now read-only.

fix(textfield): Update label position on value changed via JS #1197

Closed
3 changes: 2 additions & 1 deletion packages/mdc-textfield/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -396,8 +396,9 @@ complicated.
| --- | --- |
| addClass(className: string) => void | Adds a class to the root element |
| removeClass(className: string) => void | Removes a class from the root element |
| addClassToLabel(className: string) => void | Adds a class to the label element. We recommend you add a conditional check here, and in `removeClassFromLabel` for whether or not the label is present so that the JS component could be used with text fields that don't require a label, such as the full-width text field. |
| addClassToLabel(className: string) => void | Adds a class to the label element. We recommend you add a conditional check here, in `labelHasClass`, and in `removeClassFromLabel` for whether or not the label is present so that the JS component could be used with text fields that don't require a label, such as the full-width text field. |
| removeClassFromLabel(className: string) => void | Removes a class from the label element |
| labelHasClass(className: string) => boolean | Returns true if classname exists for the label element |
| eventTargetHasClass(target: HTMLElement, className: string) => boolean | Returns true if classname exists for a given target element |
| registerTextFieldInteractionHandler(evtType: string, handler: EventListener) => void | Registers an event handler on the root element for a given event |
| deregisterTextFieldInteractionHandler(evtType: string, handler: EventListener) => void | Deregisters an event handler on the root element for a given event |
Expand Down
7 changes: 7 additions & 0 deletions packages/mdc-textfield/adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ class MDCTextFieldAdapter {
*/
removeClassFromLabel(className) {}

/**
* Returns whether or not the label element contains the given class.
* @param {string} className
* @return {boolean}
*/
labelHasClass(className) {}

/**
* Sets an attribute on the icon Element.
* @param {string} name
Expand Down
1 change: 1 addition & 0 deletions packages/mdc-textfield/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const strings = {
ICON_SELECTOR: '.mdc-text-field__icon',
ICON_EVENT: 'MDCTextField:icon',
BOTTOM_LINE_SELECTOR: '.mdc-text-field__bottom-line',
INPUT_PROTO_PROP: 'value',
};

/** @enum {string} */
Expand Down
Loading