fix reply editor focus after draft loading

This commit is contained in:
Abhinav Raut
2026-10-22 01:12:14 +05:30
parent f0eb2235e7
commit c8463d18e3
3 changed files with 15 additions and 15 deletions
@@ -787,14 +787,4 @@ watch(
},
{ deep: true, immediate: true }
)
// Media files and macro state are restored per draft by the draft manager; resetting here would race ahead of the save and drop them.
watch(
() => conversationStore.current?.uuid,
() => {
setTimeout(() => {
activeContentRef()?.focus()
}, 100)
}
)
</script>
@@ -165,7 +165,7 @@
:message-type="messageType"
:placeholder="isCramped ? t('globals.terms.typeMessage') : t('editor.hint.full')"
:insertContent="insertContent"
:autoFocus="true"
:autoFocus="false"
:disabled="isDraftLoading"
:enableMentions="messageType === 'private_note'"
:enableConversationReferences="messageType === 'private_note'"
@@ -502,14 +502,20 @@ watch(
} else if (newType === 'private_note') {
macroStore.setCurrentView('adding_private_note')
}
// Focus editor on tab change
setTimeout(() => {
editorRef.value?.focus()
}, 50)
},
{ immediate: true }
)
watch(
[messageType, () => props.isDraftLoading, () => conversationStore.current?.uuid],
async () => {
await nextTick()
if (props.isDraftLoading || document.activeElement?.matches('input, textarea')) return
editorRef.value?.focus()
},
{ immediate: true, flush: 'post' }
)
// Expose focus method for parent components
const focus = () => {
editorRef.value?.focus()
@@ -351,7 +351,11 @@ describe('Conversation lifecycle', () => {
for (const field of ['CC', 'BCC']) {
it(`keeps ${field} open and focused while replacing an address`, () => {
cy.intercept('GET', '**/api/v1/drafts', (req) => {
req.continue((res) => res.setDelay(1000))
}).as('loadDrafts')
openConversation(ccConversationUuid)
cy.wait('@loadDrafts')
cy.get('.tiptap.ProseMirror[contenteditable="true"]').should('be.focused')
if (field === 'BCC') {
cy.contains('button', /^BCC$/).click()