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

Commit 1a5acee

Browse files
authored
feat(text-field): rename helptext to helper text (#1576)
BREAKING CHANGE: Instances of "helptext" in mdc-textfield/adapter.js has changed to "helperText", and users should update their implementations of the adapter.
1 parent 8cca080 commit 1a5acee

File tree

10 files changed

+189
-189
lines changed

10 files changed

+189
-189
lines changed

demos/text-field.html

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
<div class="mdc-toolbar-fixed-adjust"></div>
7575
<section class="hero">
7676
<div class="mdc-text-field">
77-
<input type="text" class="mdc-text-field__input" id="my-text-field" aria-controls="my-text-field-helptext">
77+
<input type="text" class="mdc-text-field__input" id="my-text-field" aria-controls="my-text-field-helper-text">
7878
<label for="my-text-field" class="mdc-text-field__label">Text Field</label>
7979
<div class="mdc-text-field__bottom-line"></div>
8080
</div>
@@ -90,13 +90,13 @@
9090
<h2>Full Functionality JS Component (Floating Label, Validation)</h2>
9191
<section id="demo-text-field-wrapper">
9292
<div class="mdc-text-field">
93-
<input type="text" class="mdc-text-field__input" id="my-text-field" aria-controls="my-text-field-helptext">
93+
<input type="text" class="mdc-text-field__input" id="my-text-field" aria-controls="my-text-field-helper-text">
9494
<label for="my-text-field" class="mdc-text-field__label">Email Address</label>
9595
<div class="mdc-text-field__bottom-line"></div>
9696
</div>
97-
<p id="my-text-field-helptext" class="mdc-text-field-helptext"
97+
<p id="my-text-field-helper-text" class="mdc-text-field-helper-text"
9898
aria-hidden="true" style="display:none;">
99-
Help Text (possibly validation message)
99+
Helper Text (possibly validation message)
100100
</p>
101101
</section>
102102
<div>
@@ -120,16 +120,16 @@ <h2>Full Functionality JS Component (Floating Label, Validation)</h2>
120120
<label for="required">Required</label>
121121
</div>
122122
<div>
123-
<input id="use-helptext" type="checkbox">
124-
<label for="use-helptext">Use Helper Text</label>
123+
<input id="use-helper-text" type="checkbox">
124+
<label for="use-helper-text">Use Helper Text</label>
125125
</div>
126126
<div>
127-
<input id="persistent-help-text" type="checkbox" disabled>
128-
<label for="persistent-help-text">Make helper text persistent</label>
127+
<input id="persistent-helper-text" type="checkbox" disabled>
128+
<label for="persistent-helper-text">Make helper text persistent</label>
129129
</div>
130130
<div>
131-
<input id="helptext-as-validation" type="checkbox" disabled>
132-
<label for="helptext-as-validation">
131+
<input id="helper-text-as-validation" type="checkbox" disabled>
132+
<label for="helper-text-as-validation">
133133
Use helper text as validation message
134134
</label>
135135
</div>
@@ -143,7 +143,7 @@ <h2>Password field with validation</h2>
143143
<label for="pw" class="mdc-text-field__label">Choose password</label>
144144
<div class="mdc-text-field__bottom-line"></div>
145145
</div>
146-
<p class="mdc-text-field-helptext mdc-text-field-helptext--persistent mdc-text-field-helptext--validation-msg"
146+
<p class="mdc-text-field-helper-text mdc-text-field-helper-text--persistent mdc-text-field-helper-text--validation-msg"
147147
id="pw-validation-msg">
148148
Must be at least 8 characters long
149149
</p>
@@ -157,7 +157,7 @@ <h2>Text Field box</h2>
157157
<label for="tf-box" class="mdc-text-field__label">Your Name</label>
158158
<div class="mdc-text-field__bottom-line"></div>
159159
</div>
160-
<p class="mdc-text-field-helptext mdc-text-field-helptext--validation-msg"
160+
<p class="mdc-text-field-helper-text mdc-text-field-helper-text--validation-msg"
161161
id="name-validation-msg">
162162
Must be at least 8 characters
163163
</p>
@@ -425,7 +425,7 @@ <h2>Full-Width Text Field and Textarea</h2>
425425
(function() {
426426
var section = document.getElementById('demo-text-field-wrapper');
427427
var tfRoot = section.querySelector('.mdc-text-field');
428-
var helptext = section.querySelector('.mdc-text-field-helptext');
428+
var helperText = section.querySelector('.mdc-text-field-helper-text');
429429
var tf = new mdc.textField.MDCTextField(tfRoot);
430430

431431
document.getElementById('disable').addEventListener('change', function(evt) {
@@ -452,23 +452,23 @@ <h2>Full-Width Text Field and Textarea</h2>
452452
var target = evt.target;
453453
tfRoot.querySelector('.mdc-text-field__input').required = target.checked;
454454
});
455-
document.getElementById('use-helptext').addEventListener('change', function(evt) {
455+
document.getElementById('use-helper-text').addEventListener('change', function(evt) {
456456
var target = evt.target;
457-
tf.helptextElement = target.checked ? helptext : null;
458-
helptext.style.display = target.checked ? 'block' : 'none';
459-
document.getElementById('persistent-help-text').disabled = !target.checked;
460-
document.getElementById('helptext-as-validation').disabled = !target.checked;
457+
tf.helperTextElement = target.checked ? helperText : null;
458+
helperText.style.display = target.checked ? 'block' : 'none';
459+
document.getElementById('persistent-helper-text').disabled = !target.checked;
460+
document.getElementById('helper-text-as-validation').disabled = !target.checked;
461461
});
462-
document.getElementById('persistent-help-text').addEventListener('change', function(evt) {
462+
document.getElementById('persistent-helper-text').addEventListener('change', function(evt) {
463463
var target = evt.target;
464-
helptext.classList[target.checked ? 'add' : 'remove'](
465-
'mdc-text-field-helptext--persistent'
464+
helperText.classList[target.checked ? 'add' : 'remove'](
465+
'mdc-text-field-helper-text--persistent'
466466
);
467467
});
468-
document.getElementById('helptext-as-validation').addEventListener('change', function(evt) {
468+
document.getElementById('helper-text-as-validation').addEventListener('change', function(evt) {
469469
var target = evt.target;
470-
helptext.classList[target.checked ? 'add' : 'remove'](
471-
'mdc-text-field-helptext--validation-msg'
470+
helperText.classList[target.checked ? 'add' : 'remove'](
471+
'mdc-text-field-helper-text--validation-msg'
472472
);
473473
});
474474
})();

demos/theme/index.html

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -780,25 +780,25 @@ <h2 class="mdc-typography--headline demo-component-section__heading">
780780
<figure class="demo-text-field-wrapper">
781781
<div class="mdc-text-field">
782782
<input type="text" class="mdc-text-field__input" id="demo-text-field-default"
783-
name="email" aria-controls="demo-text-field-default-helptext"
783+
name="email" aria-controls="demo-text-field-default-helper-text"
784784
data-demo-no-js autocomplete="email">
785785
<label for="demo-text-field-default" class="mdc-text-field__label">Default</label>
786786
<div class="mdc-text-field__bottom-line"></div>
787787
</div>
788-
<p class="mdc-text-field-helptext" id="demo-text-field-default-helptext"
788+
<p class="mdc-text-field-helper-text" id="demo-text-field-default-helper-text"
789789
aria-hidden="true">
790-
Help text
790+
Helper text
791791
</p>
792792
</figure>
793793
<figure class="demo-text-field-wrapper">
794794
<div class="mdc-text-field">
795795
<input type="text" class="mdc-text-field__input" id="demo-text-field-required" required
796-
name="email" aria-controls="demo-text-field-required-helptext"
796+
name="email" aria-controls="demo-text-field-required-helper-text"
797797
data-demo-no-js autocomplete="email">
798798
<label for="demo-text-field-required" class="mdc-text-field__label">Required</label>
799799
<div class="mdc-text-field__bottom-line"></div>
800800
</div>
801-
<p class="mdc-text-field-helptext mdc-text-field-helptext--validation-msg" id="demo-text-field-required-helptext">
801+
<p class="mdc-text-field-helper-text mdc-text-field-helper-text--validation-msg" id="demo-text-field-required-helper-text">
802802
Must provide a name
803803
</p>
804804
</figure>
@@ -809,9 +809,9 @@ <h2 class="mdc-typography--headline demo-component-section__heading">
809809
<label for="demo-text-field-box" class="mdc-text-field__label">With <code>--box</code> modifier</label>
810810
<div class="mdc-text-field__bottom-line"></div>
811811
</div>
812-
<p class="mdc-text-field-helptext" id="demo-text-field-box-helptext"
812+
<p class="mdc-text-field-helper-text" id="demo-text-field-box-helper-text"
813813
aria-hidden="true">
814-
Help text
814+
Helper text
815815
</p>
816816
</figure>
817817
</section>

packages/mdc-textfield/README.md

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -100,47 +100,47 @@ since it won't be added until that JS runs, adding it manually will prevent an i
100100
</div>
101101
```
102102

103-
### Using help text
103+
### Using helper text
104104

105-
MDC Text Fields can include help text that is useful for providing supplemental
105+
MDC Text Fields can include helper text that is useful for providing supplemental
106106
information to users, as well for validation messages (covered below).
107107

108108
```html
109109
<div class="mdc-text-field">
110-
<input type="text" id="username" class="mdc-text-field__input" aria-controls="username-helptext">
110+
<input type="text" id="username" class="mdc-text-field__input" aria-controls="username-helper-text">
111111
<label for="username" class="mdc-text-field__label">Username</label>
112112
<div class="mdc-text-field__bottom-line"></div>
113113
</div>
114-
<p id="username-helptext" class="mdc-text-field-helptext" aria-hidden="true">
114+
<p id="username-helper-text" class="mdc-text-field-helper-text" aria-hidden="true">
115115
This will be displayed on your public profile
116116
</p>
117117
```
118118

119-
Help text appears on input field focus and disappears on input field blur by default when using
119+
Helper text appears on input field focus and disappears on input field blur by default when using
120120
the text-field JS component.
121121

122-
#### Persistent help text
122+
#### Persistent helper text
123123

124-
If you'd like the help text to always be visible, add the
125-
`mdc-text-field-helptext--persistent` modifier class to the element.
124+
If you'd like the helper text to always be visible, add the
125+
`mdc-text-field-helper-text--persistent` modifier class to the element.
126126

127127
```html
128128
<div class="mdc-text-field">
129129
<input type="email" id="email" class="mdc-text-field__input">
130130
<label for="email" class="mdc-text-field__label">Email address</label>
131131
<div class="mdc-text-field__bottom-line"></div>
132132
</div>
133-
<p class="mdc-text-field-helptext mdc-text-field-helptext--persistent">
133+
<p class="mdc-text-field-helper-text mdc-text-field-helper-text--persistent">
134134
We will <em>never</em> share your email address with third parties
135135
</p>
136136
```
137137

138-
#### Help text and accessibility
138+
#### Helper text and accessibility
139139

140-
Note that in every example where the help text is dependent on the state of the input element, we
141-
assign an id to the `mdc-text-field-helptext` element and set that id to the value of the
140+
Note that in every example where the helper text is dependent on the state of the input element, we
141+
assign an id to the `mdc-text-field-helper-text` element and set that id to the value of the
142142
`aria-controls` attribute on the input element. We recommend doing this as well as it will help
143-
indicate to assistive devices that the display of the help text is dependent on the interaction with
143+
indicate to assistive devices that the display of the helper text is dependent on the interaction with
144144
the input element.
145145

146146
When using our vanilla JS component, if it sees that the input element has an `aria-controls`
@@ -165,9 +165,9 @@ By default an input's validity is checked via `checkValidity()` on blur, and the
165165
accordingly. Set the MDCTextField.valid variable to set the input's validity explicitly. MDC TextField
166166
automatically appends an asterisk to the label text if the required attribute is set.
167167

168-
Help text can be used to provide additional validation messages. Use
169-
`mdc-text-field-helptext--validation-msg` to provide styles for using the help text as a validation
170-
message. This can be easily combined with `mdc-text-field-helptext--persistent` to provide a robust
168+
Helper text can be used to provide additional validation messages. Use
169+
`mdc-text-field-helper-text--validation-msg` to provide styles for using the helper text as a validation
170+
message. This can be easily combined with `mdc-text-field-helper-text--persistent` to provide a robust
171171
UX for client-side form field validation.
172172

173173
```html
@@ -177,9 +177,9 @@ UX for client-side form field validation.
177177
<label for="pw" class="mdc-text-field__label">Choose password</label>
178178
<div class="mdc-text-field__bottom-line"></div>
179179
</div>
180-
<p class="mdc-text-field-helptext
181-
mdc-text-field-helptext--persistent
182-
mdc-text-field-helptext--validation-msg"
180+
<p class="mdc-text-field-helper-text
181+
mdc-text-field-helper-text--persistent
182+
mdc-text-field-helper-text--validation-msg"
183183
id="pw-validation-msg">
184184
Must be at least 8 characters long
185185
</p>
@@ -366,10 +366,10 @@ By default the ripple factory simply calls `new MDCRipple(el)` and returns the r
366366
Similar to regular DOM elements, the `MDCTextField` functionality is exposed through accessor
367367
methods.
368368

369-
##### MDCTextField.helptextElement
369+
##### MDCTextField.helperTextElement
370370

371371
HTMLLabelElement. This is a normal property (non-accessor) that holds a reference to the element
372-
being used as the text field's "help text". It defaults to `null`. If the text field's input element
372+
being used as the text field's "helper text". It defaults to `null`. If the text field's input element
373373
contains an `aria-controls` attribute on instantiation of the component, it will look for an element
374374
with the corresponding id within the document and automatically assign it to this property.
375375

@@ -404,16 +404,16 @@ complicated.
404404
| notifyIconAction() => void | Emits a custom event "MDCTextField:icon" denoting a user has clicked the icon |
405405
| addClassToBottomLine(className: string) => void | Adds a class to the bottom line element |
406406
| removeClassFromBottomLine(className: string) => void | Removes a class from the bottom line element |
407-
| addClassToHelptext(className: string) => void | Adds a class to the help text element. Note that in our code we check for whether or not we have a help text element and if we don't, we simply return. |
408-
| removeClassFromHelptext(className: string) => void | Removes a class from the help text element. |
409-
| helptextHasClass(className: string) => boolean | Returns whether or not the help text element contains the current class |
407+
| addClassToHelperText(className: string) => void | Adds a class to the helper text element. Note that in our code we check for whether or not we have a helper text element and if we don't, we simply return. |
408+
| removeClassFromHelperText(className: string) => void | Removes a class from the helper text element. |
409+
| helperTextHasClass(className: string) => boolean | Returns whether or not the helper text element contains the current class |
410410
| registerInputInteractionHandler(evtType: string, handler: EventListener) => void | Registers an event listener on the native input element for a given event |
411411
| deregisterInputInteractionHandler(evtType: string, handler: EventListener) => void | Deregisters an event listener on the native input element for a given event |
412412
| registerTransitionEndHandler(handler: EventListener) => void | Registers an event listener on the bottom line element for a "transitionend" event |
413413
| deregisterTransitionEndHandler(handler: EventListener) => void | Deregisters an event listener on the bottom line element for a "transitionend" event |
414414
| setBottomLineAttr(attr: string, value: string) => void | Sets an attribute with a given value on the bottom line element |
415-
| setHelptextAttr(name: string, value: string) => void | Sets an attribute with a given value on the help text element |
416-
| removeHelptextAttr(name: string) => void | Removes an attribute from the help text element |
415+
| setHelperTextAttr(name: string, value: string) => void | Sets an attribute with a given value on the helper text element |
416+
| removeHelperTextAttr(name: string) => void | Removes an attribute from the helper text element |
417417
| getNativeInput() => {value: string, disabled: boolean, badInput: boolean, checkValidity: () => boolean}? | Returns an object representing the native text input element, with a similar API shape. The object returned should include the `value`, `disabled` and `badInput` properties, as well as the `checkValidity()` function. We _never_ alter the value within our code, however we _do_ update the disabled property, so if you choose to duck-type the return value for this method in your implementation it's important to keep this in mind. Also note that this method can return null, which the foundation will handle gracefully. |
418418

419419
#### The full foundation API

packages/mdc-textfield/adapter.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -112,25 +112,25 @@ class MDCTextFieldAdapter {
112112
removeClassFromBottomLine(className) {}
113113

114114
/**
115-
* Adds a class to the help text element. Note that in our code we check for
116-
* whether or not we have a help text element and if we don't, we simply
115+
* Adds a class to the helper text element. Note that in our code we check for
116+
* whether or not we have a helper text element and if we don't, we simply
117117
* return.
118118
* @param {string} className
119119
*/
120-
addClassToHelptext(className) {}
120+
addClassToHelperText(className) {}
121121

122122
/**
123-
* Removes a class from the help text element.
123+
* Removes a class from the helper text element.
124124
* @param {string} className
125125
*/
126-
removeClassFromHelptext(className) {}
126+
removeClassFromHelperText(className) {}
127127

128128
/**
129-
* Returns whether or not the help text element contains the given class.
129+
* Returns whether or not the helper text element contains the given class.
130130
* @param {string} className
131131
* @return {boolean}
132132
*/
133-
helptextHasClass(className) {}
133+
helperTextHasClass(className) {}
134134

135135
/**
136136
* Registers an event listener on the native input element for a given event.
@@ -166,17 +166,17 @@ class MDCTextFieldAdapter {
166166
setBottomLineAttr(attr, value) {}
167167

168168
/**
169-
* Sets an attribute with a given value on the help text element.
169+
* Sets an attribute with a given value on the helper text element.
170170
* @param {string} name
171171
* @param {string} value
172172
*/
173-
setHelptextAttr(name, value) {}
173+
setHelperTextAttr(name, value) {}
174174

175175
/**
176-
* Removes an attribute from the help text element.
176+
* Removes an attribute from the helper text element.
177177
* @param {string} name
178178
*/
179-
removeHelptextAttr(name) {}
179+
removeHelperTextAttr(name) {}
180180

181181
/**
182182
* Returns an object representing the native text input element, with a

packages/mdc-textfield/constants.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ const cssClasses = {
3333
DISABLED: 'mdc-text-field--disabled',
3434
FOCUSED: 'mdc-text-field--focused',
3535
INVALID: 'mdc-text-field--invalid',
36-
HELPTEXT_PERSISTENT: 'mdc-text-field-helptext--persistent',
37-
HELPTEXT_VALIDATION_MSG: 'mdc-text-field-helptext--validation-msg',
36+
HELPER_TEXT_PERSISTENT: 'mdc-text-field-helper-text--persistent',
37+
HELPER_TEXT_VALIDATION_MSG: 'mdc-text-field-helper-text--validation-msg',
3838
LABEL_FLOAT_ABOVE: 'mdc-text-field__label--float-above',
3939
LABEL_SHAKE: 'mdc-text-field__label--shake',
4040
BOX: 'mdc-text-field--box',

0 commit comments

Comments
 (0)