Skip to content

Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.

fix(webv2): keep error styling visible on hovered inputs and media drops

Josh Corbett13f9909afa73
diff --git a/invokeai/frontend/webv2/src/features/gallery/ui/picker/GalleryMediaSlot.tsx b/invokeai/frontend/webv2/src/features/gallery/ui/picker/GalleryMediaSlot.tsx
index 0f8f8cd202..8ed3e64fd3 100644
--- a/invokeai/frontend/webv2/src/features/gallery/ui/picker/GalleryMediaSlot.tsx
+++ b/invokeai/frontend/webv2/src/features/gallery/ui/picker/GalleryMediaSlot.tsx
@@ -215,6 +215,7 @@ export const GalleryMediaSlot = ({
cursor={disabled ? 'not-allowed' : undefined}
disabled={isInert}
isDisabled={isInert}
+ isInvalid={errorMessage !== null}
isOver={isOver}
minH="20"
overflow="hidden"
diff --git a/invokeai/frontend/webv2/src/features/video/ui/VideoReferenceListField.tsx b/invokeai/frontend/webv2/src/features/video/ui/VideoReferenceListField.tsx
index 510c78060b..98114a3d51 100644
--- a/invokeai/frontend/webv2/src/features/video/ui/VideoReferenceListField.tsx
+++ b/invokeai/frontend/webv2/src/features/video/ui/VideoReferenceListField.tsx
@@ -728,6 +728,7 @@ export const VideoReferenceListField = memo(function VideoReferenceListField({
{...(isInert ? DROP_ZONE_DISABLED_PROPS : {})}
{...(isLoading ? DROP_ZONE_BUSY_PROPS : {})}
isDisabled={isInert}
+ isInvalid={errorMessage !== null}
isOver={isOver && acceptsActiveDrag}
_focusVisible={DROP_ZONE_FOCUS_PROPS}
position="relative"
@@ -760,7 +761,7 @@ export const VideoReferenceListField = memo(function VideoReferenceListField({
</DropZone>
</Field>
{errorMessage ? (
- <Text color="fg.error" fontSize="xs">
+ <Text aria-live="polite" color="fg.error" fontSize="xs" role="alert">
{errorMessage}
</Text>
) : null}
diff --git a/invokeai/frontend/webv2/src/features/workflow/ui/fields/WorkflowFieldInput.tsx b/invokeai/frontend/webv2/src/features/workflow/ui/fields/WorkflowFieldInput.tsx
index 514dfb1a7f..f0eb3748b1 100644
--- a/invokeai/frontend/webv2/src/features/workflow/ui/fields/WorkflowFieldInput.tsx
+++ b/invokeai/frontend/webv2/src/features/workflow/ui/fields/WorkflowFieldInput.tsx
@@ -156,8 +156,12 @@ export interface WorkflowFieldInputProps {
onSeedModeChange?: (seedMode: SeedMode) => void;
}
-// The media well's hover, matching DropZone's pointer-hover accent preview.
-const MEDIA_INPUT_HOVER_PROPS = { borderColor: 'accent.solid' };
+// The media well's hover matches DropZone's accent preview; an invalid well keeps its error border and tints instead.
+const MEDIA_WELL_PROPS = { _hover: { borderColor: 'accent.solid' } };
+const MEDIA_WELL_INVALID_PROPS = {
+ borderColor: 'border.error',
+ _hover: { bg: 'bg.error/60', borderColor: 'border.error' },
+};
/** A row of a list names itself by position; a scalar field is named by its title. */
type ScalarInputProps = WorkflowFieldInputProps & { ariaLabel?: string };
@@ -828,16 +832,10 @@ const ImageCollectionInput = ({
return (
<Box position="relative" w="full" {...invalidAriaProps}>
<ImageCollectionDropMonitor dropId={dropId} onDrop={appendNames} />
- <Box
- ref={setNodeRef}
- boxShadow={invalid ? '0 0 0 1px {colors.red.solid}' : undefined}
- className="nodrag"
- position="relative"
- rounded="sm"
- w="full"
- >
+ <Box ref={setNodeRef} className="nodrag" position="relative" rounded="sm" w="full">
{names.length > 0 ? (
<SimpleGrid
+ borderColor={invalid ? 'border.error' : undefined}
borderWidth="1px"
className="nowheel"
columns={3}
@@ -872,9 +870,9 @@ const ImageCollectionInput = ({
h="full"
justifyContent="center"
rounded="sm"
- transition="border-color var(--wb-motion-duration-fast) ease"
+ transition="border-color var(--wb-motion-duration-fast) ease, background var(--wb-motion-duration-fast) ease"
w="full"
- _hover={MEDIA_INPUT_HOVER_PROPS}
+ {...(invalid ? MEDIA_WELL_INVALID_PROPS : MEDIA_WELL_PROPS)}
>
<Text as="span" color="fg" fontSize="xs" fontWeight="600">
{pickerLabel}
@@ -980,15 +978,7 @@ const MediaInput = ({ id, invalid, kind, onChange, value }: WorkflowFieldInputPr
<Box position="relative" w="full" {...invalidAriaProps}>
<MediaDropMonitor dropId={dropId} kind={kind} onDrop={onMediaDrop} />
{/* The whole preview area is the drop target, like the legacy editor's widget. */}
- <Box
- ref={setNodeRef}
- boxShadow={invalid ? '0 0 0 1px {colors.red.solid}' : undefined}
- className="nodrag"
- h="32"
- position="relative"
- rounded="sm"
- w="full"
- >
+ <Box ref={setNodeRef} className="nodrag" h="32" position="relative" rounded="sm" w="full">
<GalleryPickerPopover accept={pickerAccept} label={pickerLabel} onPick={onPick}>
<chakra.button
aria-label={pickerLabel}
@@ -1007,9 +997,9 @@ const MediaInput = ({ id, invalid, kind, onChange, value }: WorkflowFieldInputPr
justifyContent="center"
overflow="hidden"
rounded="sm"
- transition="border-color var(--wb-motion-duration-fast) ease"
+ transition="border-color var(--wb-motion-duration-fast) ease, background var(--wb-motion-duration-fast) ease"
w="full"
- _hover={MEDIA_INPUT_HOVER_PROPS}
+ {...(invalid ? MEDIA_WELL_INVALID_PROPS : MEDIA_WELL_PROPS)}
>
{failedThumbnail !== mediaName ? (
<Image
@@ -1037,9 +1027,9 @@ const MediaInput = ({ id, invalid, kind, onChange, value }: WorkflowFieldInputPr
h="full"
justifyContent="center"
rounded="sm"
- transition="border-color var(--wb-motion-duration-fast) ease"
+ transition="border-color var(--wb-motion-duration-fast) ease, background var(--wb-motion-duration-fast) ease"
w="full"
- _hover={MEDIA_INPUT_HOVER_PROPS}
+ {...(invalid ? MEDIA_WELL_INVALID_PROPS : MEDIA_WELL_PROPS)}
>
<Text as="span" color="fg" fontSize="xs" fontWeight="600">
{pickerLabel}
diff --git a/invokeai/frontend/webv2/src/platform/ui/DropZone.tsx b/invokeai/frontend/webv2/src/platform/ui/DropZone.tsx
index e6215aa46e..f8d767270c 100644
--- a/invokeai/frontend/webv2/src/platform/ui/DropZone.tsx
+++ b/invokeai/frontend/webv2/src/platform/ui/DropZone.tsx
@@ -12,6 +12,8 @@ export interface DropZoneProps extends BoxProps {
disabled?: boolean;
/** The zone cannot accept input right now; the hover preview stands down. */
isDisabled?: boolean;
+ /** The last input was rejected; the error border survives pointer hover. */
+ isInvalid?: boolean;
/** A compatible drag is hovering the zone. */
isOver?: boolean;
/** Forwarded to the underlying element (e.g. dnd-kit's `setNodeRef`). */
@@ -20,21 +22,31 @@ export interface DropZoneProps extends BoxProps {
variant?: 'inline' | 'overlay';
}
-export const DropZone = ({ children, isDisabled, isOver, variant = 'inline', _hover, ...boxProps }: DropZoneProps) => {
+export const DropZone = ({
+ children,
+ isDisabled,
+ isInvalid,
+ isOver,
+ variant = 'inline',
+ _hover,
+ ...boxProps
+}: DropZoneProps) => {
// Merge hover styles so they cannot override drag-over fills; overlays use isOver instead of pointer hover.
const hoverProps = useMemo(
() => ({
...(variant === 'inline' && !isDisabled ? { borderColor: 'accent.solid' } : null),
..._hover,
+ ...(isInvalid && !isDisabled ? { bg: 'bg.error/60', borderColor: 'border.error' } : null),
...(isOver ? { bg: 'accent.solid/15', borderColor: 'accent.solid' } : null),
}),
- [_hover, isDisabled, isOver, variant]
+ [_hover, isDisabled, isInvalid, isOver, variant]
);
return (
<Box
bg={isOver ? 'accent.solid/15' : variant === 'overlay' ? 'bg.muted/60' : undefined}
- borderColor={isOver ? 'accent.solid' : 'border.emphasized'}
+ data-invalid={isInvalid || undefined}
+ borderColor={isOver ? 'accent.solid' : isInvalid ? 'border.error' : 'border.emphasized'}
borderStyle="dashed"
borderWidth={variant === 'overlay' ? '2px' : '1px'}
boxShadow={isOver && variant === 'overlay' ? '0 0 0 1px {colors.accent.solid}' : undefined}
diff --git a/invokeai/frontend/webv2/src/platform/ui/theme/recipes.ts b/invokeai/frontend/webv2/src/platform/ui/theme/recipes.ts
index f9b87ae83c..29b0b339a7 100644
--- a/invokeai/frontend/webv2/src/platform/ui/theme/recipes.ts
+++ b/invokeai/frontend/webv2/src/platform/ui/theme/recipes.ts
@@ -308,6 +308,8 @@ export const formControlInteraction = {
_invalid: { borderColor: 'border.error' },
_hover: {
borderColor: 'border.emphasized',
+ // Hover must not repaint an invalid border neutral; tint instead so hover stays visible.
+ _invalid: { borderColor: 'border.error', bg: 'bg.error/60' },
_expanded: formControlFocused,
_focusVisible: formControlFocused,
},