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

chore(textarea): handle uncontrolled default value #2712

Merged
merged 1 commit into from Aug 29, 2019
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -5,7 +5,6 @@ propComponents: ['TextArea']
typescript: true
---


import { TextArea } from '@patternfly/react-core';

## Simple text area
Expand Down Expand Up @@ -65,3 +64,13 @@ class InvalidTextArea extends React.Component {
}
}
```

## Uncontrolled text area
```js
import React from 'react';
import { TextArea } from '@patternfly/react-core';

UncontrolledTextArea = () => (
<TextArea defaultValue="default value" aria-label="uncontrolled text area example" />
)
```
Expand Up @@ -21,14 +21,12 @@ export interface TextAreaProps extends Omit<HTMLProps<HTMLTextAreaElement>, 'onC


export class TextArea extends React.Component<TextAreaProps> {

static defaultProps = {
className: '',
isRequired: false,
isValid: true,
'aria-label': null as string
}


constructor(props: TextAreaProps) {
super(props);
Expand All @@ -50,7 +48,7 @@ export class TextArea extends React.Component<TextAreaProps> {
<textarea
className={css(styles.formControl, className)}
onChange={this.handleChange}
value={value}
{...(typeof this.props.defaultValue !== 'string') && { value }}
aria-invalid={!isValid}
required={isRequired}
{...props}
Expand Down