Skip to content

Commit

Permalink
compose: Ensure topic gets set after message input focused.
Browse files Browse the repository at this point in the history
To ensure the component is shown, wait a 'safe' time of 200ms.

Also, for consistency, change topic using `handleTopicChange`
rather than a direct `setState`.
  • Loading branch information
borisyankov authored and gnprice committed Jun 30, 2018
1 parent eaa0041 commit d341054
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/compose/ComposeBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,15 @@ class ComposeBox extends PureComponent<Props, State> {
};

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 = () => {
Expand Down

0 comments on commit d341054

Please sign in to comment.