focus textarea after attachment uploads

This commit is contained in:
crockwave 2020-09-21 13:40:41 -05:00
parent 241e4ea177
commit 51031b9f99
2 changed files with 8 additions and 3 deletions

View file

@ -41,6 +41,7 @@ class ChatBox extends ImmutablePureComponent {
chat: ImmutablePropTypes.map,
onSetInputRef: PropTypes.func,
me: PropTypes.node,
onAttachment: PropTypes.func,
}
initialState = () => ({
@ -49,7 +50,6 @@ class ChatBox extends ImmutablePureComponent {
isUploading: false,
uploadProgress: 0,
resetFileKey: fileKeyGen(),
// showScroll: false,
})
state = this.initialState()
@ -129,11 +129,14 @@ class ChatBox extends ImmutablePureComponent {
setInputRef = (el) => {
const { onSetInputRef } = this.props;
this.inputElem = el;
// this.inputElem = this.textarea;
onSetInputRef(el);
};
handleAttachment = () => {
const { onAttachment } = this.props;
onAttachment(true);
}
handleRemoveFile = (e) => {
this.setState({ attachment: undefined, resetFileKey: fileKeyGen() });
}
@ -153,6 +156,7 @@ class ChatBox extends ImmutablePureComponent {
dispatch(uploadMedia(data, this.onUploadProgress)).then(response => {
this.setState({ attachment: response.data, isUploading: false });
this.handleAttachment();
}).catch(() => {
this.setState({ isUploading: false });
});

View file

@ -111,6 +111,7 @@ class ChatWindow extends ImmutablePureComponent {
<ChatBox
chatId={chat.get('id')}
onSetInputRef={this.handleInputRef}
onAttachment={this.focusInput}
/>
</div>
</div>