Merge pull request #4 from PeterTakahashi/fix/support-japanese-typing
fix: support japanese typing
This commit is contained in:
commit
506b5c1684
|
@ -8,6 +8,7 @@ interface Props {
|
||||||
|
|
||||||
export const ChatInput: FC<Props> = ({ onSend }) => {
|
export const ChatInput: FC<Props> = ({ onSend }) => {
|
||||||
const [content, setContent] = useState<string>();
|
const [content, setContent] = useState<string>();
|
||||||
|
const [isTyping, setIsTyping] = useState<boolean>(false);
|
||||||
|
|
||||||
const textareaRef = useRef<HTMLTextAreaElement>(null);
|
const textareaRef = useRef<HTMLTextAreaElement>(null);
|
||||||
|
|
||||||
|
@ -31,7 +32,7 @@ export const ChatInput: FC<Props> = ({ onSend }) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleKeyDown = (e: KeyboardEvent<HTMLTextAreaElement>) => {
|
const handleKeyDown = (e: KeyboardEvent<HTMLTextAreaElement>) => {
|
||||||
if (e.key === "Enter" && !e.shiftKey) {
|
if (!isTyping && e.key === "Enter" && !e.shiftKey) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
handleSend();
|
handleSend();
|
||||||
}
|
}
|
||||||
|
@ -54,6 +55,8 @@ export const ChatInput: FC<Props> = ({ onSend }) => {
|
||||||
placeholder="Type a message..."
|
placeholder="Type a message..."
|
||||||
value={content}
|
value={content}
|
||||||
rows={1}
|
rows={1}
|
||||||
|
onCompositionStart={() => setIsTyping(true)}
|
||||||
|
onCompositionEnd={() => setIsTyping(false)}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
onKeyDown={handleKeyDown}
|
onKeyDown={handleKeyDown}
|
||||||
/>
|
/>
|
||||||
|
|
Loading…
Reference in New Issue