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

[Input] Add read only demo #12024

Merged
merged 1 commit into from
Jul 1, 2018
Merged
Show file tree
Hide file tree
Changes from all 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
10 changes: 10 additions & 0 deletions docs/src/pages/demos/text-fields/TextFields.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,16 @@ class TextFields extends React.Component {
autoComplete="current-password"
margin="normal"
/>
<TextField
id="read-only-input"
label="Read Only"
defaultValue="Hello World"
className={classes.textField}
margin="normal"
InputProps={{
Copy link

Choose a reason for hiding this comment

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

Error: capital-case, use small case for InputProps - > inputProps

Copy link
Member Author

Choose a reason for hiding this comment

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

@jmav Both works. It was made on purpose.

Copy link

Choose a reason for hiding this comment

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

Maybe link why to be more aware, thx

Copy link
Member

Choose a reason for hiding this comment

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

Input is the react component, input is the Native element. You can provide props / attributes to both of them. The distinction os covered in the API docs.

readOnly: true,
}}
/>
<TextField
id="multiline-flexible"
label="Multiline"
Expand Down
8 changes: 4 additions & 4 deletions packages/material-ui/src/Input/Input.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -470,11 +470,11 @@ describe('<Input />', () => {

describe('prop: inputProps', () => {
it('should apply the props on the input', () => {
const wrapper = shallow(<Input inputProps={{ className: 'foo', readOnly: true }} />);
const wrapper = shallow(<Input inputProps={{ className: 'foo', maxLength: true }} />);
const input = wrapper.find('input');
assert.strictEqual(input.hasClass('foo'), true, 'should have the foo class');
assert.strictEqual(input.hasClass(classes.input), true, 'should still have the input class');
assert.strictEqual(input.props().readOnly, true, 'should have the readOnly prop');
assert.strictEqual(input.hasClass('foo'), true);
assert.strictEqual(input.hasClass(classes.input), true);
assert.strictEqual(input.props().maxLength, true);
});

it('should be able to get a ref', () => {
Expand Down