Skip to content

Commit

Permalink
Merge pull request #12289 from nextcloud/fix/focus-on-submit-button-o…
Browse files Browse the repository at this point in the history
…n-file-upload-without-caption

fix(chat): focus submit on upload attachments without caption
  • Loading branch information
ShGKme authored May 7, 2024
2 parents fcaa619 + 76e7ec2 commit c139a64
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 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(() => {
this.$refs.newMessage?.focusInput()
})
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 c139a64

Please sign in to comment.