From 016e9176f6e624b57565452f15140c2a84e99be0 Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Thu, 28 Jun 2018 18:11:52 +0100 Subject: [PATCH] Fix room topics/names reseting when UserSetting re-renders This reverts a fix to EditableText introduced in https://github.com/matrix-org/matrix-react-sdk/pull/1445 which introduced a bug that causes room name and topic to reset when UserSettings is rerendered because `initialValue != this.value` This also fixes the same bug originally fixed by #1445: >fix entering the same thing twice (which had the bug of not >emptying the "new" field) which, in other words meant that clicking "+" when adding a room alias would not reset the contents of the bottom-most alias in the list. The fix is to increment the `key` of the element, causing a new instance to be mounted instead of passing new props to the existing one. --- src/components/views/elements/EditableItemList.js | 5 ++++- src/components/views/elements/EditableText.js | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/components/views/elements/EditableItemList.js b/src/components/views/elements/EditableItemList.js index 05ae625515..02fdc96a78 100644 --- a/src/components/views/elements/EditableItemList.js +++ b/src/components/views/elements/EditableItemList.js @@ -139,8 +139,11 @@ module.exports = React.createClass({ { editableItems } { 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.