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

fix: inconsistent & wrong composer.focus() #4136

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
- fix: packaging: windows 64bit and 32bit releases now have different filenames, bring back 64bit windows releases. #4131
- some shortcuts (e.g. `Ctrl + N`, `Ctrl + K`) not working on some languages' keyboard layots #4140
- fix chat "scrolling up" when someone adds a reaction, resulting in new messages not getting scrolled into view when they arrive #4120
- message input getting unexpectedly re-focused, and not re-focused after some actions if the draft text is not empty #4136

<a id="1_46_8"></a>

Expand Down
12 changes: 7 additions & 5 deletions packages/frontend/src/components/composer/Composer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -436,8 +436,7 @@ export function useDraft(

const clearDraft = useCallback(() => {
_setDraft(_ => emptyDraft(chatId))
inputRef.current?.focus()
}, [chatId, inputRef])
}, [chatId])

const loadDraft = useCallback(
(chatId: number) => {
Expand Down Expand Up @@ -549,21 +548,24 @@ export function useDraft(
draftRef.current.quote = null
}
saveDraft()
}, [saveDraft])
inputRef.current?.focus()
}, [inputRef, saveDraft])

const removeFile = useCallback(() => {
draftRef.current.file = ''
draftRef.current.viewType = 'Text'
saveDraft()
}, [saveDraft])
inputRef.current?.focus()
}, [inputRef, saveDraft])

const addFileToDraft = useCallback(
async (file: string, viewType: Viewtype) => {
draftRef.current.file = file
draftRef.current.viewType = viewType
inputRef.current?.focus()
return saveDraft()
},
[saveDraft]
[inputRef, saveDraft]
)

const settingsStore = useSettingsStore()[0]
Expand Down
Loading