Skip to content

Commit 598f8e9

Browse files
committed
fix(chat): focus submit on upload attachments without caption
Signed-off-by: Grigorii K. Shartsev <[email protected]>
1 parent 824098e commit 598f8e9

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/components/NewMessage/NewMessageUploadEditor.vue

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
<NcButton type="tertiary" @click="handleDismiss">
5656
{{ t('spreed', 'Dismiss') }}
5757
</NcButton>
58-
<NcButton type="primary" @click="handleUpload({ caption: null, options: null})">
58+
<NcButton ref="submitButton" type="primary" @click="handleUpload({ caption: null, options: null})">
5959
{{ t('spreed', 'Send') }}
6060
</NcButton>
6161
</div>
@@ -169,21 +169,25 @@ export default {
169169
170170
watch: {
171171
async showModal(show) {
172-
if (show && this.supportMediaCaption) {
172+
if (show) {
173+
// Wait for modal content to be rendered
173174
await this.getContainerId()
174-
this.$nextTick(() => {
175+
if (this.supportMediaCaption) {
176+
// Wait for NewMessage to be rendered after containerId is set
177+
await this.$nextTick()
175178
this.$refs.newMessage?.focusInput()
176-
})
179+
} else {
180+
this.$refs.submitButton?.$el.focus()
181+
}
177182
}
178183
},
179184
},
180185
181186
methods: {
182187
async getContainerId() {
183-
this.$nextTick(() => {
184-
// Postpone render of NewMessage until modal container is mounted
185-
this.modalContainerId = `#modal-description-${this.$refs.modal.randId}`
186-
})
188+
await this.$nextTick()
189+
// Postpone render of NewMessage until modal container is mounted
190+
this.modalContainerId = `#modal-description-${this.$refs.modal.randId}`
187191
},
188192
189193
handleDismiss() {

0 commit comments

Comments
 (0)