mirror of
https://github.com/SableClient/Sable.git
synced 2026-11-20 09:01:17 -08:00
capture focus when replying to messages
This commit is contained in:
1 file changed
+18
@@ -419,6 +419,24 @@ export const RoomInput = forwardRef<HTMLDivElement, RoomInputProps>(
|
||||
}
|
||||
}, [mentionInReplies, mx, replyDraft]);
|
||||
|
||||
const prevReplyEventId = useRef(replyDraft?.eventId);
|
||||
useEffect(() => {
|
||||
if (replyDraft?.eventId !== prevReplyEventId.current) {
|
||||
prevReplyEventId.current = replyDraft?.eventId;
|
||||
|
||||
if (replyDraft?.eventId) {
|
||||
requestAnimationFrame(() => {
|
||||
try {
|
||||
ReactEditor.focus(editor);
|
||||
moveCursor(editor);
|
||||
} catch {
|
||||
// Ignore focus errors
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}, [replyDraft?.eventId, editor]);
|
||||
|
||||
const handleFileMetadata = useCallback(
|
||||
(fileItem: TUploadItem, metadata: TUploadMetadata) => {
|
||||
setSelectedFiles({
|
||||
|
||||
Reference in new issue
Block a user