Skip to content

Commit

Permalink
Merge pull request #12296 from nextcloud/backport/12289/stable29
Browse files Browse the repository at this point in the history
[stable29] fix(chat): focus submit on upload attachments without caption
  • Loading branch information
DorraJaouad authored May 23, 2024
2 parents 44f7071 + e68784b commit e020cdc
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 @@ -71,7 +71,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 @@ -185,21 +185,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 e020cdc

Please sign in to comment.