Merge pull request #2028 from matrix-org/luke/fix-room-settings-editable-text-resets
Fix room topics/names resetting when UserSetting re-renders
This commit is contained in:
commit
b07a2cb09a
2 changed files with 5 additions and 2 deletions
|
@ -139,8 +139,11 @@ module.exports = React.createClass({
|
||||||
</div>
|
</div>
|
||||||
{ editableItems }
|
{ editableItems }
|
||||||
{ this.props.canEdit ?
|
{ this.props.canEdit ?
|
||||||
|
// This is slightly evil; we want a new instance of
|
||||||
|
// EditableItem when the list grows. To make sure it's
|
||||||
|
// reset to its initial state.
|
||||||
<EditableItem
|
<EditableItem
|
||||||
key={-1}
|
key={editableItems.length}
|
||||||
initialValue={this.props.newItem}
|
initialValue={this.props.newItem}
|
||||||
onAdd={this.onItemAdded}
|
onAdd={this.onItemAdded}
|
||||||
onChange={this.onNewItemChanged}
|
onChange={this.onNewItemChanged}
|
||||||
|
|
|
@ -61,7 +61,7 @@ module.exports = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
componentWillReceiveProps: function(nextProps) {
|
componentWillReceiveProps: function(nextProps) {
|
||||||
if (nextProps.initialValue !== this.props.initialValue || nextProps.initialValue !== this.value) {
|
if (nextProps.initialValue !== this.props.initialValue) {
|
||||||
this.value = nextProps.initialValue;
|
this.value = nextProps.initialValue;
|
||||||
if (this.refs.editable_div) {
|
if (this.refs.editable_div) {
|
||||||
this.showPlaceholder(!this.value);
|
this.showPlaceholder(!this.value);
|
||||||
|
|
Loading…
Reference in a new issue