focus textarea after attachment uploads
This commit is contained in:
parent
241e4ea177
commit
51031b9f99
2 changed files with 8 additions and 3 deletions
|
@ -41,6 +41,7 @@ class ChatBox extends ImmutablePureComponent {
|
||||||
chat: ImmutablePropTypes.map,
|
chat: ImmutablePropTypes.map,
|
||||||
onSetInputRef: PropTypes.func,
|
onSetInputRef: PropTypes.func,
|
||||||
me: PropTypes.node,
|
me: PropTypes.node,
|
||||||
|
onAttachment: PropTypes.func,
|
||||||
}
|
}
|
||||||
|
|
||||||
initialState = () => ({
|
initialState = () => ({
|
||||||
|
@ -49,7 +50,6 @@ class ChatBox extends ImmutablePureComponent {
|
||||||
isUploading: false,
|
isUploading: false,
|
||||||
uploadProgress: 0,
|
uploadProgress: 0,
|
||||||
resetFileKey: fileKeyGen(),
|
resetFileKey: fileKeyGen(),
|
||||||
// showScroll: false,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
state = this.initialState()
|
state = this.initialState()
|
||||||
|
@ -129,11 +129,14 @@ class ChatBox extends ImmutablePureComponent {
|
||||||
|
|
||||||
setInputRef = (el) => {
|
setInputRef = (el) => {
|
||||||
const { onSetInputRef } = this.props;
|
const { onSetInputRef } = this.props;
|
||||||
this.inputElem = el;
|
|
||||||
// this.inputElem = this.textarea;
|
|
||||||
onSetInputRef(el);
|
onSetInputRef(el);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
handleAttachment = () => {
|
||||||
|
const { onAttachment } = this.props;
|
||||||
|
onAttachment(true);
|
||||||
|
}
|
||||||
|
|
||||||
handleRemoveFile = (e) => {
|
handleRemoveFile = (e) => {
|
||||||
this.setState({ attachment: undefined, resetFileKey: fileKeyGen() });
|
this.setState({ attachment: undefined, resetFileKey: fileKeyGen() });
|
||||||
}
|
}
|
||||||
|
@ -153,6 +156,7 @@ class ChatBox extends ImmutablePureComponent {
|
||||||
|
|
||||||
dispatch(uploadMedia(data, this.onUploadProgress)).then(response => {
|
dispatch(uploadMedia(data, this.onUploadProgress)).then(response => {
|
||||||
this.setState({ attachment: response.data, isUploading: false });
|
this.setState({ attachment: response.data, isUploading: false });
|
||||||
|
this.handleAttachment();
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
this.setState({ isUploading: false });
|
this.setState({ isUploading: false });
|
||||||
});
|
});
|
||||||
|
|
|
@ -111,6 +111,7 @@ class ChatWindow extends ImmutablePureComponent {
|
||||||
<ChatBox
|
<ChatBox
|
||||||
chatId={chat.get('id')}
|
chatId={chat.get('id')}
|
||||||
onSetInputRef={this.handleInputRef}
|
onSetInputRef={this.handleInputRef}
|
||||||
|
onAttachment={this.focusInput}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue