Skip to content

fix: focus message input after Quote/Edit from context menu - #305

Closed
7PH wants to merge 1 commit into
masterfrom
fix/context-menu-focus-input
Closed

fix: focus message input after Quote/Edit from context menu#305
7PH wants to merge 1 commit into
masterfrom
fix/context-menu-focus-input

Conversation

@7PH

@7PH 7PH commented Jun 23, 2026

Copy link
Copy Markdown
Member

Problem

Right-clicking a message and selecting Reply or Edit from the context menu did not focus the message textarea.

Root cause: SkyContextMenu is built on Radix Vue's ContextMenuRoot, which restores focus to the trigger element after the menu closes — using requestAnimationFrame. This fired after the app.newMessage watcher in NewMessageForm.vue had already called .focus() on the textarea, effectively stealing focus back.

Fix

In quoteMessage and editMessage inside SingleMessage.vue:

  • Import and call useMessageComposer() to get the composer API (already registered by NewMessageForm.vue)
  • After app.setMessage(...), schedule setTimeout(() => composer.value?.focus(), 0)

setTimeout(0) is a macro task that runs after requestAnimationFrame callbacks, so our focus call wins reliably regardless of which trigger path is used (context menu or hover toolbar).

Scope

  • Only SingleMessage.vue is changed (4 lines: 1 import, 1 composable call, 2 setTimeout calls)
  • No changes to the store, composable, or NewMessageForm.vue
  • The hover toolbar Reply/Edit buttons already worked and continue to work (the setTimeout(0) is harmless for non-Radix paths)

Radix Vue's ContextMenu restores focus to the trigger element after the
menu closes (via requestAnimationFrame). This ran after the app.newMessage
watcher in NewMessageForm fired its .focus() call, stealing focus back.

Fix: schedule a setTimeout(0) focus via useMessageComposer in quoteMessage
and editMessage. setTimeout(0) runs after requestAnimationFrame, so our
focus call wins regardless of which path triggered the action (context menu
or hover toolbar).
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@7PH

7PH commented Aug 23, 2026

Copy link
Copy Markdown
Member Author

Cherry-picked into #302 (c5b57a4)

@7PH 7PH closed this Aug 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant