Add auto focus to chat message send box.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { Input, Spin } from "antd";
|
||||
import { LoadingOutlined } from "@ant-design/icons";
|
||||
import React, { useState, useEffect } from "react";
|
||||
import React, { useState, useEffect, useRef } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
@@ -23,11 +23,12 @@ function ChatSendMessageComponent({
|
||||
isSending,
|
||||
}) {
|
||||
const [message, setMessage] = useState("");
|
||||
|
||||
const inputArea = useRef(null);
|
||||
useEffect(() => {
|
||||
if (isSending === false) {
|
||||
setMessage("");
|
||||
}
|
||||
inputArea.current.focus();
|
||||
}, [isSending, setMessage]);
|
||||
|
||||
const { t } = useTranslation();
|
||||
@@ -46,6 +47,7 @@ function ChatSendMessageComponent({
|
||||
<Input.TextArea
|
||||
allowClear
|
||||
autoFocus
|
||||
ref={inputArea}
|
||||
suffix={<span>a</span>}
|
||||
autoSize={{ minRows: 1, maxRows: 4 }}
|
||||
value={message}
|
||||
|
||||
Reference in New Issue
Block a user