mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
Adds enter keydown > generate
This commit is contained in:
parent
b74354795d
commit
e30827e19b
@ -1,5 +1,8 @@
|
||||
import { Textarea } from '@chakra-ui/react';
|
||||
import { ChangeEvent } from 'react';
|
||||
import {
|
||||
ChangeEvent,
|
||||
KeyboardEvent,
|
||||
} from 'react';
|
||||
import { useAppDispatch, useAppSelector } from '../../app/hooks';
|
||||
import { RootState } from '../../app/store';
|
||||
import { setPrompt } from '../sd/sdSlice';
|
||||
@ -14,6 +17,13 @@ const PromptInput = () => {
|
||||
const handleChangePrompt = (e: ChangeEvent<HTMLTextAreaElement>) =>
|
||||
dispatch(setPrompt(e.target.value));
|
||||
|
||||
const handleKeyDown = (e: KeyboardEvent<HTMLTextAreaElement>) => {
|
||||
if (e.key === 'Enter' && e.shiftKey === false) {
|
||||
e.preventDefault();
|
||||
dispatch(generateImage())
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Textarea
|
||||
id="prompt"
|
||||
@ -23,6 +33,7 @@ const PromptInput = () => {
|
||||
height={'100%'}
|
||||
isInvalid={!prompt.length}
|
||||
onChange={handleChangePrompt}
|
||||
onKeyDown={handleKeyDown}
|
||||
value={prompt}
|
||||
placeholder="I'm dreaming of..."
|
||||
/>
|
||||
|
Loading…
Reference in New Issue
Block a user