From d341054e45543508461bcba4579f369ca62d80af Mon Sep 17 00:00:00 2001 From: Boris Yankov Date: Thu, 28 Jun 2018 04:53:12 +0200 Subject: [PATCH] compose: Ensure topic gets set after message input focused. To ensure the component is shown, wait a 'safe' time of 200ms. Also, for consistency, change topic using `handleTopicChange` rather than a direct `setState`. --- src/compose/ComposeBox.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/compose/ComposeBox.js b/src/compose/ComposeBox.js index 58b9141449a..68477ad8324 100644 --- a/src/compose/ComposeBox.js +++ b/src/compose/ComposeBox.js @@ -131,12 +131,15 @@ class ComposeBox extends PureComponent { }; handleMessageFocus = () => { + const { topic } = this.state; const { lastMessageTopic } = this.props; - this.setState(({ topic }) => ({ + this.setState({ isMessageFocused: true, isMenuExpanded: false, - topic: topic || lastMessageTopic, - })); + }); + setTimeout(() => { + this.handleTopicChange(topic || lastMessageTopic); + }, 200); // wait, to hope the component is shown }; handleMessageBlur = () => {