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 the seed input's error description on ark 5.39

Josh Corbett604b378a32bd
diff --git a/invokeai/frontend/webv2/src/features/workflow/core/document.ts b/invokeai/frontend/webv2/src/features/workflow/core/document.ts
index f74aa24334..fc34887250 100644
--- a/invokeai/frontend/webv2/src/features/workflow/core/document.ts
+++ b/invokeai/frontend/webv2/src/features/workflow/core/document.ts
@@ -533,9 +533,10 @@ const applyProjectGraphAction = (document: ProjectGraphState, action: ProjectGra
case 'setFieldSeedMode': {
// Fixed is the absent default, so choosing it leaves the instance exactly as
// pre-seed-mode documents (and legacy readers) write it.
- return setFieldInstance(document, action.nodeId, action.fieldName, ({ seedMode: _, ...instance }) =>
- action.seedMode === 'fixed' ? instance : { ...instance, seedMode: action.seedMode }
- );
+ return setFieldInstance(document, action.nodeId, action.fieldName, (instance) => {
+ const { seedMode: _, ...withoutSeedMode } = instance;
+ return action.seedMode === 'fixed' ? withoutSeedMode : { ...instance, seedMode: action.seedMode };
+ });
}
case 'advanceSeedFields': {
return action.advances.reduce((next, advance) => {
diff --git a/invokeai/frontend/webv2/src/platform/ui/SeedInput.browser.test.tsx b/invokeai/frontend/webv2/src/platform/ui/SeedInput.browser.test.tsx
index 1fb718acd8..d02dc0dbf7 100644
--- a/invokeai/frontend/webv2/src/platform/ui/SeedInput.browser.test.tsx
+++ b/invokeai/frontend/webv2/src/platform/ui/SeedInput.browser.test.tsx
@@ -234,6 +234,39 @@ describe('SeedInput', () => {
expect(seedInput()?.getAttribute('aria-describedby')).toBe(errorId);
});
+ it("describes the input with the field's help text ahead of the preview", async () => {
+ await act(() => {
+ root.render(
+ <ChakraProvider value={system}>
+ <Field helpText="Any whole number" label="Seed">
+ <Host initialSeed={42} seedMode="increment" onCommit={vi.fn()} />
+ </Field>
+ </ChakraProvider>
+ );
+ });
+
+ const helperId = host.querySelector('[data-part="helper-text"]')?.id;
+ const previewId = host.querySelector('[data-testid="seed-sequence-preview"]')?.id;
+
+ expect(helperId).toBeTruthy();
+ expect(seedInput()?.getAttribute('aria-describedby')).toBe(`${helperId} ${previewId}`);
+ });
+
+ it('never names an error text the field does not render', async () => {
+ await act(() => {
+ root.render(
+ <ChakraProvider value={system}>
+ <Field invalid label="Seed">
+ <Host initialSeed={42} seedMode="fixed" onCommit={vi.fn()} />
+ </Field>
+ </ChakraProvider>
+ );
+ });
+
+ expect(seedInput()?.getAttribute('aria-invalid')).toBe('true');
+ expect(seedInput()?.getAttribute('aria-describedby')).toBeNull();
+ });
+
it('renders an empty field for an absent seed without committing anything', async () => {
const onCommit = await renderHost('fixed', undefined);
diff --git a/invokeai/frontend/webv2/src/platform/ui/SeedInput.tsx b/invokeai/frontend/webv2/src/platform/ui/SeedInput.tsx
index 3802b96df7..d0c1e4addb 100644
--- a/invokeai/frontend/webv2/src/platform/ui/SeedInput.tsx
+++ b/invokeai/frontend/webv2/src/platform/ui/SeedInput.tsx
@@ -158,10 +158,13 @@ export const SeedInput = ({
const { t } = useTranslation();
const previewId = useId();
const isRandom = seedMode === 'random';
- // Inside a Field the input is already described by the field's error and helper text; the
- // preview joins that list rather than replacing it.
+ // Inside a Field the input stays described by the field's helper and error text, and the preview
+ // joins that list. Ark 5.39 moved the error id from `ariaDescribedby` to its input props' error message.
const field = useFieldContext();
- const describedBy = [field?.ariaDescribedby, plan ? previewId : undefined].filter(Boolean).join(' ') || undefined;
+ const describedBy =
+ [field?.ariaDescribedby, field?.getInputProps()['aria-errormessage'], plan ? previewId : undefined]
+ .filter(Boolean)
+ .join(' ') || undefined;
// The host's id goes through zag's id map, never onto the element: zag syncs the DOM value
// by looking the input up under its own id, so an overriding `id` leaves an external change
// (the dice, a recall, an advance) invisible until the next keystroke.