Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
fix(dify-ui): preserve invalid focus colors and remove shadow transitions (#42108)
yyh1dcfe38171d0
diff --git a/packages/dify-ui/src/autocomplete/index.tsx b/packages/dify-ui/src/autocomplete/index.tsxindex e42c71f5484..3d1fc3f4c29 100644--- a/packages/dify-ui/src/autocomplete/index.tsx+++ b/packages/dify-ui/src/autocomplete/index.tsx@@ -81,7 +81,7 @@ const autocompleteItemClassName = [const autocompleteInputGroupVariants = cva([- 'group/autocomplete flex w-full min-w-0 items-center border border-transparent bg-components-input-bg-normal text-components-input-text-filled shadow-none outline-hidden transition-[background-color,border-color,box-shadow]',+ 'group/autocomplete flex w-full min-w-0 items-center border border-transparent bg-components-input-bg-normal text-components-input-text-filled shadow-none outline-hidden transition-[background-color,border-color]','hover:border-components-input-border-hover hover:bg-components-input-bg-hover',textControlCompoundInputFocusClassName,'data-focused:border-components-input-border-active data-focused:bg-components-input-bg-active data-focused:shadow-xs',diff --git a/packages/dify-ui/src/combobox/index.tsx b/packages/dify-ui/src/combobox/index.tsxindex aa4819d4fdc..4afcebf7f1f 100644--- a/packages/dify-ui/src/combobox/index.tsx+++ b/packages/dify-ui/src/combobox/index.tsx@@ -145,7 +145,7 @@ function ComboboxTrigger({const comboboxInputGroupVariants = cva([- 'group/combobox flex w-full min-w-0 items-center border border-transparent bg-components-input-bg-normal text-components-input-text-filled shadow-none outline-hidden transition-[background-color,border-color,box-shadow]',+ 'group/combobox flex w-full min-w-0 items-center border border-transparent bg-components-input-bg-normal text-components-input-text-filled shadow-none outline-hidden transition-[background-color,border-color]','hover:border-components-input-border-hover hover:bg-components-input-bg-hover',textControlCompoundInputFocusClassName,'data-focused:border-components-input-border-active data-focused:bg-components-input-bg-active data-focused:shadow-xs',diff --git a/packages/dify-ui/src/input-group/__tests__/index.spec.tsx b/packages/dify-ui/src/input-group/__tests__/index.spec.tsxindex c71d99db541..90b4667a441 100644--- a/packages/dify-ui/src/input-group/__tests__/index.spec.tsx+++ b/packages/dify-ui/src/input-group/__tests__/index.spec.tsx@@ -148,3 +148,45 @@ describe('InputGroup', () => {await expect.element(addonButton).toHaveFocus()})})++describe('Invalid focus colors', () => {+ it.each(['light', 'dark'])(+ 'preserves error colors through keyboard and pointer focus in %s',+ async (theme) => {+ const previousTheme = document.documentElement.dataset.theme+ document.documentElement.dataset.theme = theme+ try {+ const screen = await render(+ <>+ <Button>Before</Button>+ <Field invalid>+ <FieldLabel>Invalid value</FieldLabel>+ <InputGroup data-testid="invalid-surface">+ <InputGroupInput defaultValue="Invalid value" />+ <InputGroupAddon>suffix</InputGroupAddon>+ </InputGroup>+ </Field>+ </>,+ )+ const input = screen.getByRole('textbox', { name: 'Invalid value' })+ const surface = screen.getByTestId('invalid-surface').element()+ const colors = () => {+ const style = getComputedStyle(surface)+ return [style.borderTopColor, style.backgroundColor]+ }+ const restingColors = colors()+ const restingShadow = getComputedStyle(surface).boxShadow+ await screen.getByRole('button', { name: 'Before' }).click()+ await userEvent.keyboard('{Tab}')+ await expect.element(input).toHaveFocus()+ await expect.element(input).toHaveAttribute('aria-invalid', 'true')+ await expect.poll(colors).toEqual(restingColors)+ await expect.poll(() => getComputedStyle(surface).boxShadow).not.toBe(restingShadow)+ await input.click()+ await expect.poll(colors).toEqual(restingColors)+ } finally {+ document.documentElement.dataset.theme = previousTheme+ }+ },+ )+})diff --git a/packages/dify-ui/src/input-group/index.stories.tsx b/packages/dify-ui/src/input-group/index.stories.tsxindex 8f8a322d19e..1b7280396d3 100644--- a/packages/dify-ui/src/input-group/index.stories.tsx+++ b/packages/dify-ui/src/input-group/index.stories.tsx@@ -8,7 +8,7 @@ import {DropdownMenuItem,DropdownMenuTrigger,} from '../dropdown-menu'-import { Field, FieldDescription, FieldLabel } from '../field'+import { Field, FieldDescription, FieldError, FieldLabel } from '../field'import { IconButton } from '../icon-button'import { InputGroup, InputGroupAddon, InputGroupInput } from './index'@@ -216,3 +216,23 @@ export const WithDropdownAction: Story = {})},}++export const Invalid: Story = {+ render: () => (+ <Field invalid className="w-80">+ <FieldLabel>Repository URL</FieldLabel>+ <InputGroup>+ <InputGroupInput defaultValue="invalid repository" />+ <InputGroupAddon className="pe-0">https://</InputGroupAddon>+ </InputGroup>+ <FieldError match>Please enter a valid repository URL.</FieldError>+ </Field>+ ),+ play: async ({ canvas, userEvent }) => {+ const input = canvas.getByRole('textbox', { name: 'Repository URL' })+ await userEvent.click(input)+ await expect(input).toHaveFocus()+ await expect(input).toHaveAttribute('aria-invalid', 'true')+ await expect(input).toHaveAccessibleDescription('Please enter a valid repository URL.')+ },+}diff --git a/packages/dify-ui/src/input-group/index.tsx b/packages/dify-ui/src/input-group/index.tsxindex 82bce9271fe..68cbe7113c9 100644--- a/packages/dify-ui/src/input-group/index.tsx+++ b/packages/dify-ui/src/input-group/index.tsx@@ -19,9 +19,9 @@ function InputGroup({ className, onMouseDown, ...props }: InputGroupProps) {{...props}className={cn([- 'flex min-h-8 w-full min-w-0 items-center rounded-lg border border-transparent bg-components-input-bg-normal transition-[background-color,border-color,box-shadow]',- 'has-[>input:enabled]:not-has-[>input[readonly]]:hover:border-components-input-border-hover has-[>input:enabled]:not-has-[>input[readonly]]:hover:bg-components-input-bg-hover',- 'has-[>input:focus]:not-has-[>input[readonly]]:border-components-input-border-active has-[>input:focus]:not-has-[>input[readonly]]:bg-components-input-bg-active has-[>input:focus]:not-has-[>input[readonly]]:shadow-xs',+ 'flex min-h-8 w-full min-w-0 items-center rounded-lg border border-transparent bg-components-input-bg-normal transition-[background-color,border-color]',+ 'has-[>input:enabled]:not-has-[>input:is([readonly],[data-invalid])]:hover:border-components-input-border-hover has-[>input:enabled]:not-has-[>input:is([readonly],[data-invalid])]:hover:bg-components-input-bg-hover',+ 'has-[>input:focus]:not-has-[>input:is([readonly],[data-invalid])]:border-components-input-border-active has-[>input:focus]:not-has-[>input:is([readonly],[data-invalid])]:bg-components-input-bg-active has-[>input:focus]:not-has-[>input[readonly]]:shadow-xs','has-[>input[data-invalid]]:border-components-input-border-destructive has-[>input[data-invalid]]:bg-components-input-bg-destructive','has-[>input[data-disabled]]:cursor-not-allowed has-[>input[data-disabled]]:border-transparent has-[>input[data-disabled]]:bg-components-input-bg-disabled has-[>input[data-disabled]]:text-components-input-text-filled-disabled','has-[>input[data-disabled]]:*:data-align:cursor-not-allowed has-[>input[data-disabled]]:*:data-align:text-components-input-text-filled-disabled',diff --git a/packages/dify-ui/src/input/index.tsx b/packages/dify-ui/src/input/index.tsxindex 9a7aa121e99..34352023e94 100644--- a/packages/dify-ui/src/input/index.tsx+++ b/packages/dify-ui/src/input/index.tsx@@ -14,7 +14,7 @@ function Input({ className, ...props }: InputProps) {<BaseInputclassName={cn([- 'w-full appearance-none rounded-lg border border-transparent bg-components-input-bg-normal px-3 py-1.75 system-sm-regular text-components-input-text-filled caret-primary-600 outline-hidden transition-[background-color,border-color,box-shadow]',+ 'w-full appearance-none rounded-lg border border-transparent bg-components-input-bg-normal px-3 py-1.75 system-sm-regular text-components-input-text-filled caret-primary-600 outline-hidden transition-[background-color,border-color]','placeholder:text-components-input-text-placeholder','hover:border-components-input-border-hover hover:bg-components-input-bg-hover',textControlFocusClassName,diff --git a/packages/dify-ui/src/number-field/__tests__/index.spec.tsx b/packages/dify-ui/src/number-field/__tests__/index.spec.tsxindex a0c6955a9e1..39e6b4453fc 100644--- a/packages/dify-ui/src/number-field/__tests__/index.spec.tsx+++ b/packages/dify-ui/src/number-field/__tests__/index.spec.tsx@@ -9,6 +9,7 @@ import type {import * as React from 'react'import { userEvent } from 'vite-plus/test/browser'import { render } from 'vitest-browser-react'+import { Button } from '../../button'import { Field, FieldLabel } from '../../field'import {NumberField,@@ -258,3 +259,46 @@ describe('NumberField wrapper', () => {})})})++describe('Invalid focus colors', () => {+ it.each(['light', 'dark'])(+ 'preserves error colors through keyboard and pointer focus in %s',+ async (theme) => {+ const previousTheme = document.documentElement.dataset.theme+ document.documentElement.dataset.theme = theme+ try {+ const screen = await render(+ <>+ <Button>Before</Button>+ <Field invalid>+ <FieldLabel>Invalid value</FieldLabel>+ <NumberField defaultValue={120}>+ <NumberFieldGroup data-testid="invalid-surface">+ <NumberFieldInput />+ </NumberFieldGroup>+ </NumberField>+ </Field>+ </>,+ )+ const input = screen.getByRole('textbox', { name: 'Invalid value' })+ const surface = screen.getByTestId('invalid-surface').element()+ const colors = () => {+ const style = getComputedStyle(surface)+ return [style.borderTopColor, style.backgroundColor]+ }+ const restingColors = colors()+ const restingShadow = getComputedStyle(surface).boxShadow+ await screen.getByRole('button', { name: 'Before' }).click()+ await userEvent.keyboard('{Tab}')+ await expect.element(input).toHaveFocus()+ await expect.element(input).toHaveAttribute('aria-invalid', 'true')+ await expect.poll(colors).toEqual(restingColors)+ await expect.poll(() => getComputedStyle(surface).boxShadow).not.toBe(restingShadow)+ await input.click()+ await expect.poll(colors).toEqual(restingColors)+ } finally {+ document.documentElement.dataset.theme = previousTheme+ }+ },+ )+})diff --git a/packages/dify-ui/src/number-field/index.tsx b/packages/dify-ui/src/number-field/index.tsxindex 087317b1b63..4f6db3b8f85 100644--- a/packages/dify-ui/src/number-field/index.tsx+++ b/packages/dify-ui/src/number-field/index.tsx@@ -12,11 +12,12 @@ type NumberFieldProps = BaseNumberField.Root.Propsconst numberFieldGroupVariants = cva([- 'group/number-field flex w-full min-w-0 items-stretch overflow-hidden border border-transparent bg-components-input-bg-normal text-components-input-text-filled shadow-none outline-hidden transition-[background-color,border-color,box-shadow]',+ 'group/number-field flex w-full min-w-0 items-stretch overflow-hidden border border-transparent bg-components-input-bg-normal text-components-input-text-filled shadow-none outline-hidden transition-[background-color,border-color]','hover:border-components-input-border-hover hover:bg-components-input-bg-hover',textControlCompoundInputFocusClassName,'data-focused:border-components-input-border-active data-focused:bg-components-input-bg-active data-focused:shadow-xs','data-invalid:border-components-input-border-destructive data-invalid:bg-components-input-bg-destructive',+ 'data-invalid:has-[input:focus]:border-components-input-border-destructive data-invalid:has-[input:focus]:bg-components-input-bg-destructive','data-disabled:cursor-not-allowed data-disabled:border-transparent data-disabled:bg-components-input-bg-disabled data-disabled:text-components-input-text-filled-disabled','data-disabled:hover:border-transparent data-disabled:hover:bg-components-input-bg-disabled','data-readonly:shadow-none data-readonly:hover:border-transparent data-readonly:hover:bg-components-input-bg-normal motion-reduce:transition-none',diff --git a/packages/dify-ui/src/textarea/index.tsx b/packages/dify-ui/src/textarea/index.tsxindex cb7df46f876..2ec656416db 100644--- a/packages/dify-ui/src/textarea/index.tsx+++ b/packages/dify-ui/src/textarea/index.tsx@@ -10,7 +10,7 @@ import { textControlFocusClassName } from '../form-control-shared'const textareaVariants = cva([- 'min-h-20 w-full appearance-none overflow-auto border border-transparent bg-components-input-bg-normal text-components-input-text-filled caret-primary-600 outline-hidden transition-[background-color,border-color,box-shadow]',+ 'min-h-20 w-full appearance-none overflow-auto border border-transparent bg-components-input-bg-normal text-components-input-text-filled caret-primary-600 outline-hidden transition-[background-color,border-color]','placeholder:text-components-input-text-placeholder','hover:border-components-input-border-hover hover:bg-components-input-bg-hover',textControlFocusClassName,