-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
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
[TextField] proposal: read-only prop #9790
Comments
How is it different from using the |
Good point, I didn't know about it, the only annoying part is that the field has still the focusable effect https://codesandbox.io/s/lp7z7zkp1z even in read-only But that's native https://jsfiddle.net/crl/70jw3nah/ too so I can manage that myself Thanks, I will close I'd still want maybe a way to disable the Input's inkbar, when it's readOnly, will see what I can do |
@caub Great. Here is the answer in case codesandbox lost this piece of code: import React from 'react';
import { render } from 'react-dom';
import TextField from './TextField';
import Button from 'material-ui/Button';
class App extends React.Component {
state = {readOnly: true}
render() {
const {readOnly} = this.state;
return (
<div>
<TextField
inputProps={{
readOnly: Boolean(readOnly),
disabled: Boolean(readOnly),
}}
required
fullWidth={true}
label="Name"
name="name"
margin="normal"
defaultValue={"test"}
/>
<Button raised
onClick={e => {this.setState({readOnly: !readOnly})}}>
{readOnly ? 'edit' : 'review'}
</Button>
</div>
)
}
}
render(<App />, document.getElementById('root')); |
I am having weird issue with this, if I have an empty readonly TextField and update its value on later state change, I can see overlapping label and value. |
Sorry false alarm, I missed setting initial state parameter |
It would interesting to be able to switch easily between a "presentation"/review mode and an editable mode
Like disabled prop, but not with that opacity
Let me make a codesandox demonstrating it
The text was updated successfully, but these errors were encountered: