Skip to content

Commit

Permalink
fix(chat): focus submit on upload attachments without caption
Browse files Browse the repository at this point in the history
Signed-off-by: Grigorii K. Shartsev <[email protected]>
  • Loading branch information
ShGKme committed May 7, 2024
1 parent 824098e commit 598f8e9
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/components/NewMessage/NewMessageUploadEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
<NcButton type="tertiary" @click="handleDismiss">
{{ t('spreed', 'Dismiss') }}
</NcButton>
<NcButton type="primary" @click="handleUpload({ caption: null, options: null})">
<NcButton ref="submitButton" type="primary" @click="handleUpload({ caption: null, options: null})">
{{ t('spreed', 'Send') }}
</NcButton>
</div>
Expand Down Expand Up @@ -169,21 +169,25 @@ export default {

watch: {
async showModal(show) {
if (show && this.supportMediaCaption) {
if (show) {
// Wait for modal content to be rendered
await this.getContainerId()
this.$nextTick(() => {
if (this.supportMediaCaption) {
// Wait for NewMessage to be rendered after containerId is set
await this.$nextTick()
this.$refs.newMessage?.focusInput()
})
} else {
this.$refs.submitButton?.$el.focus()
}
}
},
},

methods: {
async getContainerId() {
this.$nextTick(() => {
// Postpone render of NewMessage until modal container is mounted
this.modalContainerId = `#modal-description-${this.$refs.modal.randId}`
})
await this.$nextTick()
// Postpone render of NewMessage until modal container is mounted
this.modalContainerId = `#modal-description-${this.$refs.modal.randId}`
},

handleDismiss() {
Expand Down

0 comments on commit 598f8e9

Please sign in to comment.