mirror of
https://github.com/invoke-ai/InvokeAI.git
synced 2026-04-23 03:00:31 -04:00
per(ui): move field desc content to own component
This commit is contained in:
@@ -21,15 +21,7 @@ type Props = {
|
||||
};
|
||||
|
||||
export const InputFieldDescriptionPopover = memo(({ nodeId, fieldName }: Props) => {
|
||||
const dispatch = useAppDispatch();
|
||||
const { t } = useTranslation();
|
||||
const description = useInputFieldDescription(nodeId, fieldName);
|
||||
const onChange = useCallback(
|
||||
(e: ChangeEvent<HTMLTextAreaElement>) => {
|
||||
dispatch(fieldDescriptionChanged({ nodeId, fieldName, val: e.target.value }));
|
||||
},
|
||||
[dispatch, fieldName, nodeId]
|
||||
);
|
||||
|
||||
return (
|
||||
<Popover isLazy lazyBehavior="unmount">
|
||||
@@ -44,21 +36,38 @@ export const InputFieldDescriptionPopover = memo(({ nodeId, fieldName }: Props)
|
||||
/>
|
||||
</PopoverTrigger>
|
||||
<PopoverContent p={2} w={256}>
|
||||
<FormControl orientation="vertical">
|
||||
<FormLabel>{t('nodes.description')}</FormLabel>
|
||||
<Textarea
|
||||
className="nodrag nopan nowheel"
|
||||
fontSize="sm"
|
||||
value={description ?? ''}
|
||||
onChange={onChange}
|
||||
p={2}
|
||||
resize="none"
|
||||
rows={5}
|
||||
/>
|
||||
</FormControl>
|
||||
<Content nodeId={nodeId} fieldName={fieldName} />
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
);
|
||||
});
|
||||
|
||||
InputFieldDescriptionPopover.displayName = 'InputFieldDescriptionPopover';
|
||||
|
||||
const Content = memo(({ nodeId, fieldName }: Props) => {
|
||||
const dispatch = useAppDispatch();
|
||||
const { t } = useTranslation();
|
||||
const description = useInputFieldDescription(nodeId, fieldName);
|
||||
const onChange = useCallback(
|
||||
(e: ChangeEvent<HTMLTextAreaElement>) => {
|
||||
dispatch(fieldDescriptionChanged({ nodeId, fieldName, val: e.target.value }));
|
||||
},
|
||||
[dispatch, fieldName, nodeId]
|
||||
);
|
||||
|
||||
return (
|
||||
<FormControl orientation="vertical">
|
||||
<FormLabel>{t('nodes.description')}</FormLabel>
|
||||
<Textarea
|
||||
className="nodrag nopan nowheel"
|
||||
fontSize="sm"
|
||||
value={description ?? ''}
|
||||
onChange={onChange}
|
||||
p={2}
|
||||
resize="none"
|
||||
rows={5}
|
||||
/>
|
||||
</FormControl>
|
||||
);
|
||||
});
|
||||
Content.displayName = 'Content';
|
||||
|
||||
Reference in New Issue
Block a user