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): select the whole number on double-click in workflow fields

Josh Corbettccfa6449ccf6
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 fed56a5ff3..af57e5d7c4 100644
--- a/invokeai/frontend/webv2/src/features/workflow/ui/fields/WorkflowFieldInput.tsx
+++ b/invokeai/frontend/webv2/src/features/workflow/ui/fields/WorkflowFieldInput.tsx
@@ -70,8 +70,19 @@ import {
import { MiddleTruncate } from '@platform/ui/MiddleTruncate';
import { SeedInput } from '@platform/ui/SeedInput';
import { useQuery, useQueryClient } from '@tanstack/react-query';
-import { FilmIcon, ImageIcon, Trash2Icon } from 'lucide-react';
-import { lazy, Suspense, useCallback, useEffect, useId, useMemo, useRef, useState, type ChangeEvent } from 'react';
+import { FilmIcon, ImageIcon, ImagePlusIcon, Trash2Icon, XIcon } from 'lucide-react';
+import {
+ lazy,
+ Suspense,
+ useCallback,
+ useEffect,
+ useId,
+ useMemo,
+ useRef,
+ useState,
+ type ChangeEvent,
+ type MouseEvent,
+} from 'react';
import { useTranslation } from 'react-i18next';
const ModelSelect = lazy(() => import('@features/models/react').then((module) => ({ default: module.ModelSelect })));
@@ -164,6 +175,9 @@ const StringInput = ({ id, invalid, onChange, template, value }: WorkflowFieldIn
const NumericInput = ({ id, invalid, onChange, template, value }: WorkflowFieldInputProps) => {
const isInteger = template.type.name === 'IntegerField';
const numericValue = typeof value === 'number' && Number.isFinite(value) ? value : '';
+/** A double-click anywhere in the box selects the whole value, not just the word under the pointer. */
+const selectInputText = (event: MouseEvent<HTMLInputElement>) => event.currentTarget.select();
+
const min = template.minimum ?? template.exclusiveMinimum ?? undefined;
const max = template.maximum ?? template.exclusiveMaximum ?? undefined;
const onInputChange = useCallback(
@@ -194,6 +208,7 @@ const NumericInput = ({ id, invalid, onChange, template, value }: WorkflowFieldI
/>
);
};
+ onDoubleClick={selectInputText}
/**
* The shared seed control under a workflow row. The workflow owns the value
diff --git a/invokeai/frontend/webv2/src/platform/ui/SeedInput.tsx b/invokeai/frontend/webv2/src/platform/ui/SeedInput.tsx
index d0c1e4addb..41cd7bcaed 100644
--- a/invokeai/frontend/webv2/src/platform/ui/SeedInput.tsx
+++ b/invokeai/frontend/webv2/src/platform/ui/SeedInput.tsx
@@ -5,7 +5,7 @@ import type { LucideIcon } from 'lucide-react';
import { HStack, Icon, Menu, NumberInput, Portal, Stack, Text, useFieldContext } from '@chakra-ui/react';
import { SEED_MAX, SEED_MODES } from '@platform/core/seed';
import { ChevronDownIcon, DicesIcon, LocateFixedIcon, MinusIcon, PlusIcon, ShuffleIcon } from 'lucide-react';
-import { useId, useMemo } from 'react';
+import { useId, useMemo, type MouseEvent } from 'react';
import { useTranslation } from 'react-i18next';
import { Button, IconButton } from './Button';
@@ -14,6 +14,8 @@ import { Tooltip } from './Tooltip';
const SEED_MODE_MENU_POSITIONING = { placement: 'bottom-end' } as const;
const TABULAR_NUMS = { fontVariantNumeric: 'tabular-nums' } as const;
+
+const selectInputText = (event: MouseEvent<HTMLInputElement>) => event.currentTarget.select();
const SEED_MODE_ICONS: Record<SeedMode, LucideIcon> = {
decrement: MinusIcon,
fixed: LocateFixedIcon,
@@ -196,7 +198,12 @@ export const SeedInput = ({
}}
>
<NumberInput.Control />
- <NumberInput.Input aria-describedby={describedBy} aria-label={ariaLabel} css={TABULAR_NUMS} />
+ <NumberInput.Input
+ aria-describedby={describedBy}
+ aria-label={ariaLabel}
+ css={TABULAR_NUMS}
+ onDoubleClick={selectInputText}
+ />
</NumberInput.Root>
{/* The tooltip is the visible hint; the accessible name stays on the button because a
tooltip only describes its trigger while open. */}