Skip to content
This repository was archived by the owner on May 24, 2024. It is now read-only.

Commit 9d2d436

Browse files
pranav300mjhenkes
andauthored
[terra-form-input][terra-form-textarea] Remove prop placeholder (#3075)
* removed placeholder prop from input * removed placeholder prop from textarea * Removed/Updated tests and examples * Updated search field due to changes in form-input * minor changes * minor changes * updated documentation * minor changes * comments * reverted changes made to search-field Co-authored-by: Matt Henkes <[email protected]>
1 parent 0b9f37a commit 9d2d436

File tree

63 files changed

+87
-385
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+87
-385
lines changed

packages/terra-form-input/CHANGELOG.md

+9
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@ ChangeLog
33

44
Unreleased
55
----------
6+
### Breaking Changes
7+
* Removed `placeholder` prop.
8+
9+
### Changed
10+
* Updated tests and examples to not use `placeholder` prop
11+
12+
### Removed
13+
* Removed theme variables - see UPGRADEGUIDE.md
14+
* Removed tests and examples specifically for `placeholder` prop
615

716
3.7.0 - (July 7, 2020)
817
------------------

packages/terra-form-input/src/Input.jsx

+4-7
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,6 @@ const propTypes = {
5050
* NOTE: The pattern attribute works with the following input types: text, date, search, url, tel, email, and password.
5151
*/
5252
pattern: PropTypes.string,
53-
/**
54-
* Placeholder text.
55-
*/
56-
placeholder: PropTypes.string,
5753
/**
5854
* Callback ref to pass into the input dom element.
5955
*/
@@ -90,7 +86,6 @@ const defaultProps = {
9086
onFocus: undefined,
9187
name: null,
9288
pattern: undefined,
93-
placeholder: undefined,
9489
required: false,
9590
refCallback: undefined,
9691
type: undefined,
@@ -109,7 +104,6 @@ class Input extends React.Component {
109104
onFocus,
110105
name,
111106
pattern,
112-
placeholder,
113107
refCallback,
114108
required,
115109
type,
@@ -154,6 +148,10 @@ class Input extends React.Component {
154148
attributes.defaultValue = defaultValue;
155149
}
156150

151+
if (attributes.placeholder) {
152+
attributes.placeholder = null;
153+
}
154+
157155
return (
158156
<input
159157
{...attributes}
@@ -163,7 +161,6 @@ class Input extends React.Component {
163161
name={name}
164162
type={type}
165163
pattern={pattern}
166-
placeholder={placeholder}
167164
onBlur={onBlur}
168165
onChange={onChange}
169166
onFocus={onFocus}

packages/terra-form-input/src/Input.module.scss

-11
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,6 @@
2626
transition-timing-function: var(--terra-form-input-transition-timing-function, ease);
2727
width: 100%;
2828

29-
&::placeholder {
30-
color: var(--terra-form-input-placeholder-color, rgba(25, 32, 35, 0.53));
31-
font-style: var(--terra-form-input-placeholder-font-style);
32-
opacity: 1;
33-
}
34-
3529
&:hover {
3630
background-color: var(--terra-form-input-hover-background-color, #fff);
3731
border: var(--terra-form-input-hover-border, 1px solid #dedfe0);
@@ -51,11 +45,6 @@
5145
pointer-events: none;
5246
}
5347

54-
&[disabled]::placeholder {
55-
color: var(--terra-form-input-placeholder-disabled-color, rgba(25, 32, 35, 0.53));
56-
font-style: var(--terra-form-input-placeholder-disabled-font-style);
57-
}
58-
5948
&:focus {
6049
background-color: var(--terra-form-input-focus-background-color, #fff);
6150
background-size: var(--terra-form-input-focus-background-size);

packages/terra-form-input/src/InputField.jsx

+4-7
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,6 @@ const propTypes = {
7575
* Function to trigger when user changes the input value. Provide a function to create a controlled input.
7676
*/
7777
onChange: PropTypes.func,
78-
/**
79-
* Placeholder text.
80-
*/
81-
placeholder: PropTypes.string,
8278
/**
8379
* Ref callback to pass into the ref attribute of the html input element.
8480
*/
@@ -118,7 +114,6 @@ const defaultProps = {
118114
isLabelHidden: false,
119115
labelAttrs: {},
120116
onChange: undefined,
121-
placeholder: undefined,
122117
maxWidth: undefined,
123118
refCallback: undefined,
124119
required: false,
@@ -145,7 +140,6 @@ const InputField = (props) => {
145140
labelAttrs,
146141
maxWidth,
147142
onChange,
148-
placeholder,
149143
refCallback,
150144
required,
151145
showOptional,
@@ -170,6 +164,10 @@ const InputField = (props) => {
170164

171165
const inputType = type || inputAttrs.type;
172166

167+
if (customProps.placeholder) {
168+
customProps.placeholder = null;
169+
}
170+
173171
return (
174172
<Field
175173
label={label}
@@ -194,7 +192,6 @@ const InputField = (props) => {
194192
isIncomplete={isIncomplete}
195193
type={inputType}
196194
onChange={onChange}
197-
placeholder={placeholder || inputAttrs.placeholder}
198195
value={value}
199196
defaultValue={defaultValue}
200197
refCallback={refCallback}

packages/terra-form-input/src/clinical-lowlight-theme/Input.module.scss

-5
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
--terra-form-input-disabled-border: 1px solid #242b2b;
2121
--terra-form-input-disabled-color: #404344;
2222
--terra-form-input-disabled-opacity: 0.25;
23-
--terra-form-input-placeholder-disabled-font-style: normal;
2423

2524
--terra-form-input-focus-background-color: #222a2e;
2625
--terra-form-input-focus-border: 1px solid #004c76;
@@ -34,10 +33,6 @@
3433
--terra-form-input-error-focus-border: 1px solid #004c76;
3534
--terra-form-input-error-hover-border: 1px solid #181b1d;
3635

37-
--terra-form-input-placeholder-color: #6f7477;
38-
--terra-form-input-placeholder-disabled-color: #6f7477;
39-
--terra-form-input-placeholder-font-style: normal;
40-
4136
--terra-form-input-background-image: none;
4237
--terra-form-input-background-size: auto;
4338

packages/terra-form-input/src/orion-fusion-theme/Input.module.scss

-8
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,6 @@
3232
--terra-form-input-focus-ltr-box-shadow: 0 0 8px #a6d9f4;
3333
--terra-form-input-focus-rtl-box-shadow: 0 0 8px #a6d9f4;
3434

35-
// Placeholder
36-
--terra-form-input-placeholder-color: #767676;
37-
--terra-form-input-placeholder-font-style: normal;
38-
39-
// Placeholder - Disabled
40-
--terra-form-input-placeholder-disabled-color: #c4c6c7;
41-
--terra-form-input-placeholder-disabled-font-style: normal;
42-
4335
// Disabled
4436
--terra-form-input-disabled-background-color: #f4f4f4;
4537
--terra-form-input-disabled-border: 1px solid #b2b5b6;

packages/terra-form-input/src/terra-dev-site/doc/common/NumberInputExample.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import Input from 'terra-form-input';
55
const NumberInputExample = () => (
66
<div>
77
<Field label="Numeric Input" htmlFor="numeric">
8-
<Input name="number input" placeholder="Enter Digits" id="numeric" type="number" ariaLabel="Numeric Input" />
8+
<Input name="number input" id="numeric" type="number" ariaLabel="Numeric Input" />
99
</Field>
1010
</div>
1111
);

packages/terra-form-input/src/terra-dev-site/doc/common/PlaceholderExample.jsx

-13
This file was deleted.

packages/terra-form-input/src/terra-dev-site/doc/example/InputField.jsx

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ const DefaultInputField = () => (
77
label="Profile Name"
88
help="Note: This can not be changed in the future"
99
type="text"
10-
placeholder="Profile Name"
1110
inputAttrs={{
1211
name: 'profile',
1312
}}

packages/terra-form-input/src/terra-dev-site/doc/example/NumberInputField.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const NumberInputField = () => (
66
inputId="numeric-input"
77
label="Numeric Value"
88
type="number"
9-
placeholder="Enter Digits"
9+
help="Enter Digits"
1010
inputAttrs={{
1111
name: 'numeric',
1212
}}

packages/terra-form-input/src/terra-dev-site/doc/form-input/Input.1.doc.mdx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { Badge } from 'terra-form-input/package.json?dev-site-package';
22

33
import BlankExample from '../common/BlankExample?dev-site-example';
4-
import PlaceholderExample from '../common/PlaceholderExample?dev-site-example';
54
import NumberInputExample from '../common/NumberInputExample?dev-site-example';
65
import ControlledDefaultExample from '../example/controlled/DefaultExample?dev-site-example';
76
import ControlledDisabledExample from '../example/controlled/DisabledExample?dev-site-example';
@@ -24,6 +23,8 @@ import FormInputPropsTable from 'terra-form-input/src/Input?dev-site-props-table
2423

2524
Generic input which represents an HTML input element directly.
2625

26+
**Note:** To follow [UX Best Practices](https://www.w3.org/WAI/GL/low-vision-a11y-tf/wiki/Placeholder_Research), this component does not allow `placeholder`.
27+
2728
## Getting Started
2829

2930
- Install with [npmjs](https://www.npmjs.com):
@@ -55,7 +56,6 @@ import Input from 'terra-form-input';
5556

5657
## Examples
5758
<BlankExample title="Default Input" />
58-
<PlaceholderExample title="Placeholder Input" />
5959
<NumberInputExample title="Numeric Input" />
6060
<ControlledDefaultExample title="Controlled Example - Valid" />
6161
<ControlledDisabledExample title="Controlled Example - Valid Disabled" />

packages/terra-form-input/src/terra-dev-site/doc/form-input/InputField.2.doc.mdx

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import FormInputFieldPropsTable from 'terra-form-input/src/InputField?dev-site-p
1414
[terra-form-input](https://github.com/cerner/terra-core/tree/main/packages/terra-form-input) component that is wrapped inside a
1515
[terra-form-field](https://github.com/cerner/terra-core/tree/main/packages/terra-form-field) component.
1616

17+
**Note:** To follow [UX Best Practices](https://www.w3.org/WAI/GL/low-vision-a11y-tf/wiki/Placeholder_Research), this component does not allow `placeholder`.
18+
1719
## Getting Started
1820

1921
- Install with [npmjs](https://www.npmjs.com):

packages/terra-form-input/src/terra-dev-site/doc/form-input/UpgradeGuide.3.doc.mdx

+21
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,27 @@ import { Badge } from 'terra-form-input/package.json?dev-site-package';
33
<Badge />
44

55
# Terra Form Input Upgrade Guide
6+
## Changes from version 3 to version 4
7+
8+
### Props
9+
10+
#### Removed
11+
* Removed `placeholder` prop from `Input` and `InputField`.
12+
13+
### Changes to CSS Custom Properties
14+
15+
#### Removed
16+
* --terra-form-input-placeholder-color
17+
* --terra-form-input-placeholder-font-style
18+
* --terra-form-input-placeholder-disabled-color
19+
* --terra-form-input-placeholder-disabled-font-style
20+
21+
##### Steps to Upgrade
22+
To upgrade from 3.0 to 4.0 each existing Input and InputField must be reviewed and updated to ensure no `placeholder` prop is passed to it. This is done to follow WCAG ([for more info](https://www.w3.org/WAI/GL/low-vision-a11y-tf/wiki/Placeholder_Research)).
23+
24+
* `Input` component will not be supporting `placeholder` prop and `native placeholder`. If consumers want to provide a detailed text guidance they can upgrade to `InputField`.
25+
26+
* `InputField` component will not be supporting `placeholder` prop and `native placeholder`. But consumers may utilize the `help` text field properties to provide similar guidance to the user using `help` prop.
627

728
## Changes from version 2 to version 3
829

packages/terra-form-input/src/terra-dev-site/test/form-input/DisabledPlaceholderInput.test.jsx

-14
This file was deleted.

packages/terra-form-input/src/terra-dev-site/test/form-input/PlaceholderFormInput.test.jsx

-14
This file was deleted.

packages/terra-form-input/tests/jest/Input.test.jsx

-6
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,6 @@ describe('Input', () => {
2323
expect(wrapper).toMatchSnapshot();
2424
});
2525

26-
it('should render w/ placeholder text when just a placeholder prop is passed into the Input', () => {
27-
const input = <Input placeholder="foo" ariaLabel="label" />;
28-
const wrapper = shallow(input);
29-
expect(wrapper).toMatchSnapshot();
30-
});
31-
3226
it('should render as controlled when just a default value and `onChange()` is passed into the Input', () => {
3327
const input = <Input value="foo" onChange={() => { }} />;
3428
const wrapper = shallow(input);

packages/terra-form-input/tests/jest/InputField.test.jsx

-12
Original file line numberDiff line numberDiff line change
@@ -145,16 +145,4 @@ describe('InputField', () => {
145145
const wrapper = shallow(textarea);
146146
expect(wrapper).toMatchSnapshot();
147147
});
148-
149-
it('should render a placeholder within the InputField component', () => {
150-
const textarea = <InputField inputId="test-input" label="Label" placeholder="Placeholder" />;
151-
const wrapper = shallow(textarea);
152-
expect(wrapper).toMatchSnapshot();
153-
});
154-
155-
it('should render a placeholder within the InputField component when passed as an input attribute', () => {
156-
const textarea = <InputField inputId="test-input" label="Label" inputAttrs={{ placeholder: 'Placeholder' }} />;
157-
const wrapper = shallow(textarea);
158-
expect(wrapper).toMatchSnapshot();
159-
});
160148
});

packages/terra-form-input/tests/jest/__snapshots__/Input.test.jsx.snap

-11
Original file line numberDiff line numberDiff line change
@@ -115,17 +115,6 @@ exports[`Input should render as uncontrolled when just a default value is passed
115115
/>
116116
`;
117117

118-
exports[`Input should render w/ placeholder text when just a placeholder prop is passed into the Input 1`] = `
119-
<input
120-
aria-label="label"
121-
className="form-input"
122-
disabled={false}
123-
name={null}
124-
placeholder="foo"
125-
required={false}
126-
/>
127-
`;
128-
129118
exports[`Input should render with a type of password and pattern prop value 1`] = `
130119
<input
131120
aria-label="label"

0 commit comments

Comments
 (0)