fix: focus message input after Quote/Edit from context menu - #305
Closed
7PH wants to merge 1 commit into
Closed
Conversation
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).
|
Member
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.




Problem
Right-clicking a message and selecting Reply or Edit from the context menu did not focus the message textarea.
Root cause:
SkyContextMenuis built on Radix Vue'sContextMenuRoot, which restores focus to the trigger element after the menu closes — usingrequestAnimationFrame. This fired after theapp.newMessagewatcher inNewMessageForm.vuehad already called.focus()on the textarea, effectively stealing focus back.Fix
In
quoteMessageandeditMessageinsideSingleMessage.vue:useMessageComposer()to get the composer API (already registered byNewMessageForm.vue)app.setMessage(...), schedulesetTimeout(() => composer.value?.focus(), 0)setTimeout(0)is a macro task that runs afterrequestAnimationFramecallbacks, so our focus call wins reliably regardless of which trigger path is used (context menu or hover toolbar).Scope
SingleMessage.vueis changed (4 lines: 1 import, 1 composable call, 2 setTimeout calls)NewMessageForm.vuesetTimeout(0)is harmless for non-Radix paths)