Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable29] fix(chat): focus submit on upload attachments without caption #12296

Merged
merged 1 commit into from
May 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading