We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
<EditableText placeholder={this.state.placeholder} />
e.g. this.setState({ placeholder: "new-placeholder" })
The value in the EditableText should remain the same
The value in the EditableText is cleared
EditableText resets its state value in componentWillReceiveProps, which seems very wrong when the component's value is uncontrolled.
componentWillReceiveProps
The text was updated successfully, but these errors were encountered:
I needed something in ~10 minutes, so I used the following as a quick, temporary workaround:
import * as React from "react"; import { EditableText, IEditableTextProps } from "@blueprintjs/core"; interface UncontrolledEditableTextState { value: string; } interface UncontrolledEditableTextProps extends IEditableTextProps { value?: null; onChange?: null; } export class UncontrolledEditableText extends React.PureComponent<UncontrolledEditableTextProps, UncontrolledEditableTextState> { constructor(props: UncontrolledEditableTextProps) { super(props); this.state = { value: props.defaultValue, }; } componentWillReceiveProps(nextProps: UncontrolledEditableTextProps) { if (nextProps.defaultValue !== this.props.defaultValue) { this.setState({ value: nextProps.defaultValue, }); } } render() { return ( <EditableText {...this.props} value={this.state.value} onChange={this.handleChange} onCancel={this.handleCancel} /> ); } private handleChange = (value: string) => { this.setState({ value }); } private handleCancel = (value: string) => { this.setState({ value }); if (this.props.onCancel) { this.props.onCancel(value); } } }
Sorry, something went wrong.
giladgray
No branches or pull requests
Bug report
Steps to reproduce
<EditableText placeholder={this.state.placeholder} />
)e.g. this.setState({ placeholder: "new-placeholder" })
)Actual behavior
The value in the EditableText should remain the same
Expected behavior
The value in the EditableText is cleared
Hypothesis for the underlying issue
EditableText resets its state value in
componentWillReceiveProps
, which seems very wrong when the component's value is uncontrolled.The text was updated successfully, but these errors were encountered: