Only apply Textaera to Prompt

This commit is contained in:
mickr777 2023-07-21 13:17:27 +10:00 committed by GitHub
parent 98b2734240
commit 585520d8d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,4 +1,4 @@
import { Textarea } from '@chakra-ui/react'; import { Textarea, Input } from '@chakra-ui/react';
import { useAppDispatch } from 'app/store/storeHooks'; import { useAppDispatch } from 'app/store/storeHooks';
import { fieldValueChanged } from 'features/nodes/store/nodesSlice'; import { fieldValueChanged } from 'features/nodes/store/nodesSlice';
import { import {
@ -19,7 +19,9 @@ const StringInputFieldComponent = (
const { nodeId, field, nodeWidth } = props; const { nodeId, field, nodeWidth } = props;
const dispatch = useAppDispatch(); const dispatch = useAppDispatch();
const handleValueChanged = (e: ChangeEvent<HTMLTextAreaElement>) => { const handleValueChanged = (
e: ChangeEvent<HTMLInputElement | HTMLTextAreaElement>
) => {
dispatch( dispatch(
fieldValueChanged({ fieldValueChanged({
nodeId, nodeId,
@ -32,16 +34,26 @@ const StringInputFieldComponent = (
const textareaWidth = nodeWidth - 20; const textareaWidth = nodeWidth - 20;
return ( return (
<Textarea <>
style={{ {field.name.toLowerCase() === 'prompt' ? (
height: '150px', <Textarea
width: `${textareaWidth}px`, style={{
resize: 'none', height: '150px',
overflowY: 'auto', width: `${textareaWidth}px`,
}} resize: 'none',
onChange={handleValueChanged} overflowY: 'auto',
value={field.value} }}
/> onChange={handleValueChanged}
value={field.value}
/>
) : (
<Input
style={{ width: `${textareaWidth}px` }}
onChange={handleValueChanged}
value={field.value}
/>
)}
</>
); );
}; };