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.
TypeScript ai-artartificial-intelligencegenerative-artimage-generationimg2imginpaintinglatent-diffusionlinuxmacosoutpaintingstable-diffusiontxt2imgwindows
fix(theme): keep spinners moving under reduce-motion, slowed
joshistoastfd9192548854
diff --git a/invokeai/frontend/webv2/src/platform/ui/theme/SpinnerReducedMotion.browser.test.tsx b/invokeai/frontend/webv2/src/platform/ui/theme/SpinnerReducedMotion.browser.test.tsxnew file mode 100644index 0000000000..e0b2e3c928--- /dev/null+++ b/invokeai/frontend/webv2/src/platform/ui/theme/SpinnerReducedMotion.browser.test.tsx@@ -0,0 +1,63 @@+import { ChakraProvider, Skeleton, Spinner } from '@chakra-ui/react';+import { system } from '@theme/system';+import { act } from 'react';+import { createRoot, type Root } from 'react-dom/client';+import { afterEach, describe, expect, it } from 'vitest';++/**+ * Reduce-motion kills every animation token, which froze spinners into a+ * static arc that reads as a broken icon. A loading spinner is essential+ * status (WCAG 2.3.3 exempts essential motion), so it slows instead.+ */++let host: HTMLDivElement | null = null;+let root: Root | null = null;+(globalThis as typeof globalThis & { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT = true;++afterEach(async () => {+ await act(() => root?.unmount());+ host?.remove();+ delete document.documentElement.dataset.reduceMotion;+ host = null;+ root = null;+});++const render = async () => {+ host = document.createElement('div');+ document.body.append(host);+ root = createRoot(host);++ await act(() =>+ root?.render(+ <ChakraProvider value={system}>+ <Spinner data-testid="spinner" size="sm" />+ <Skeleton data-testid="skeleton" h="4" w="20" />+ </ChakraProvider>+ )+ );++ return {+ skeleton: getComputedStyle(host.querySelector('[data-testid="skeleton"]')!),+ spinner: getComputedStyle(host.querySelector('[data-testid="spinner"]')!),+ };+};++describe('spinner under reduce-motion', () => {+ it('spins normally with motion enabled', async () => {+ const { spinner } = await render();++ expect(spinner.animationName).not.toBe('none');+ expect(spinner.animationDuration).toBe('0.5s');+ });++ it('slows instead of freezing with motion reduced, while skeletons stay still', async () => {+ document.documentElement.dataset.reduceMotion = 'true';++ const { skeleton, spinner } = await render();++ expect(spinner.animationName).not.toBe('none');+ expect(spinner.animationDuration).toBe('2s');+ expect(spinner.animationIterationCount).toBe('infinite');+ expect(skeleton.animationName).toBe('none');+ });+});diff --git a/invokeai/frontend/webv2/src/platform/ui/theme/system.ts b/invokeai/frontend/webv2/src/platform/ui/theme/system.tsindex c57f3806fd..8a4b8fe58e 100644--- a/invokeai/frontend/webv2/src/platform/ui/theme/system.ts+++ b/invokeai/frontend/webv2/src/platform/ui/theme/system.ts@@ -260,6 +260,14 @@ const config = defineConfig({':root[data-reduce-motion="true"] .chakra-skeleton': {animation: 'none !important',},+ // A loading spinner is essential status, not decoration — frozen, its arc+ // reads as a broken icon. It slows to a crawl instead of stopping; WCAG+ // 2.3.3 targets non-essential motion only. (Chakra's indeterminate+ // progress circle already behaves this way: its raw `spin 2s` shorthand+ // bypasses the animation tokens the reduce-motion condition nulls out.)+ ':root[data-reduce-motion="true"] .chakra-spinner': {+ animation: 'spin 2s linear infinite !important',+ },},theme: {tokens: {