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(web): make the human input expander a button (#40202)
yyh2a34c7a71449
diff --git a/oxlint-suppressions.json b/oxlint-suppressions.jsonindex 578512c2c93..c68d29a0450 100644--- a/oxlint-suppressions.json+++ b/oxlint-suppressions.json@@ -820,14 +820,6 @@"count": 1}},- "web/app/components/base/chat/chat/answer/human-input-content/content-wrapper.tsx": {- "jsx_a11y/click-events-have-key-events": {- "count": 1- },- "jsx_a11y/no-static-element-interactions": {- "count": 1- }- },"web/app/components/base/chat/chat/answer/suggested-questions.tsx": {"jsx_a11y/click-events-have-key-events": {"count": 1diff --git a/web/app/components/base/chat/chat/answer/human-input-content/__tests__/content-wrapper.spec.tsx b/web/app/components/base/chat/chat/answer/human-input-content/__tests__/content-wrapper.spec.tsxindex 9e50c9c18bf..34e1df25447 100644--- a/web/app/components/base/chat/chat/answer/human-input-content/__tests__/content-wrapper.spec.tsx+++ b/web/app/components/base/chat/chat/answer/human-input-content/__tests__/content-wrapper.spec.tsx@@ -1,46 +1,70 @@+import type { ComponentProps } from 'react'import { render, screen } from '@testing-library/react'import userEvent from '@testing-library/user-event'import { describe, expect, it } from 'vitest'import ContentWrapper from '../content-wrapper'describe('ContentWrapper', () => {- const defaultProps = {- nodeTitle: 'Human Input Node',- children: <div data-testid="child-content">Child Content</div>,- }+ const renderContentWrapper = (+ props: Omit<ComponentProps<typeof ContentWrapper>, 'children' | 'nodeTitle'> = {},+ ) =>+ render(+ <ContentWrapper nodeTitle="Human Input Node" {...props}>+ <div data-testid="child-content">Child Content</div>+ </ContentWrapper>,+ )it('should render node title and children by default when not collapsible', () => {- render(<ContentWrapper {...defaultProps} />)+ renderContentWrapper()expect(screen.getByText('Human Input Node')).toBeInTheDocument()expect(screen.getByTestId('child-content')).toBeInTheDocument()- expect(screen.queryByTestId('expand-icon')).not.toBeInTheDocument()+ expect(screen.queryByRole('button')).not.toBeInTheDocument()})it('should show/hide content when toggling expansion', async () => {const user = userEvent.setup()- render(<ContentWrapper {...defaultProps} showExpandIcon={true} expanded={false} />)+ renderContentWrapper({ showExpandIcon: true, expanded: false })- // Initially collapsedexpect(screen.queryByTestId('child-content')).not.toBeInTheDocument()- const expandToggle = screen.getByTestId('expand-icon')- expect(expandToggle.querySelector('.i-ri-arrow-right-s-line')).toBeInTheDocument()+ const expandToggle = screen.getByRole('button', {+ name: 'share.chat.expand Human Input Node',+ })+ expect(expandToggle).toHaveAttribute('aria-expanded', 'false')- // Expandawait user.click(expandToggle)expect(screen.getByTestId('child-content')).toBeInTheDocument()- expect(expandToggle.querySelector('.i-ri-arrow-down-s-line')).toBeInTheDocument()+ const collapseToggle = screen.getByRole('button', {+ name: 'share.chat.collapse Human Input Node',+ })+ expect(collapseToggle).toHaveAttribute('aria-expanded', 'true')- // Collapse- await user.click(expandToggle)+ await user.click(collapseToggle)expect(screen.queryByTestId('child-content')).not.toBeInTheDocument()})+ it.each([+ ['Enter', '{Enter}'],+ ['Space', ' '],+ ])('should expand with the %s key', async (_, key) => {+ const user = userEvent.setup()+ renderContentWrapper({ showExpandIcon: true, expanded: false })++ const expandToggle = screen.getByRole('button', {+ name: 'share.chat.expand Human Input Node',+ })+ expandToggle.focus()+ await user.keyboard(key)++ expect(screen.getByTestId('child-content')).toBeInTheDocument()+ })+it('should render children initially if expanded is true', () => {- render(<ContentWrapper {...defaultProps} showExpandIcon={true} expanded={true} />)+ renderContentWrapper({ showExpandIcon: true, expanded: true })expect(screen.getByTestId('child-content')).toBeInTheDocument()- const expandToggle = screen.getByTestId('expand-icon')- expect(expandToggle.querySelector('.i-ri-arrow-down-s-line')).toBeInTheDocument()+ expect(+ screen.getByRole('button', { name: 'share.chat.collapse Human Input Node' }),+ ).toHaveAttribute('aria-expanded', 'true')})})diff --git a/web/app/components/base/chat/chat/answer/human-input-content/content-wrapper.tsx b/web/app/components/base/chat/chat/answer/human-input-content/content-wrapper.tsxindex 73eac8fed19..c20ba265a39 100644--- a/web/app/components/base/chat/chat/answer/human-input-content/content-wrapper.tsx+++ b/web/app/components/base/chat/chat/answer/human-input-content/content-wrapper.tsx@@ -1,5 +1,6 @@import { cn } from '@langgenius/dify-ui/cn'import { useCallback, useState } from 'react'+import { useTranslation } from 'react-i18next'import BlockIcon from '@/app/components/workflow/block-icon'import { BlockEnum } from '@/app/components/workflow/types'@@ -18,6 +19,7 @@ const ContentWrapper = ({className,expanded = false,}: ContentWrapperProps) => {+ const { t } = useTranslation()const [isExpanded, setIsExpanded] = useState(expanded)const handleToggleExpand = useCallback(() => {@@ -43,17 +45,23 @@ const ContentWrapper = ({{nodeTitle}</div>{showExpandIcon && (- <div- className="shrink-0 cursor-pointer"+ <button+ type="button"+ aria-expanded={isExpanded}+ aria-label={`${+ isExpanded+ ? t(($) => $['chat.collapse'], { ns: 'share' })+ : t(($) => $['chat.expand'], { ns: 'share' })+ } ${nodeTitle}`}+ className="flex size-4 shrink-0 cursor-pointer appearance-none items-center justify-center focus-visible:ring-2 focus-visible:ring-state-accent-solid focus-visible:outline-hidden"onClick={handleToggleExpand}- data-testid="expand-icon">{isExpanded ? (- <div className="i-ri-arrow-down-s-line size-4" />+ <span aria-hidden className="i-ri-arrow-down-s-line size-4" />) : (- <div className="i-ri-arrow-right-s-line size-4" />+ <span aria-hidden className="i-ri-arrow-right-s-line size-4" />)}- </div>+ </button>)}</div>{(!showExpandIcon || isExpanded) && (diff --git a/web/app/components/workflow/panel/__tests__/human-input-filled-form-list.spec.tsx b/web/app/components/workflow/panel/__tests__/human-input-filled-form-list.spec.tsxindex f113b499406..cdc03f92b8d 100644--- a/web/app/components/workflow/panel/__tests__/human-input-filled-form-list.spec.tsx+++ b/web/app/components/workflow/panel/__tests__/human-input-filled-form-list.spec.tsx@@ -45,8 +45,12 @@ describe('HumanInputFilledFormList', () => {'Approved by Alice',)- await user.click(screen.getAllByTestId('expand-icon')[0]!)+ const collapseApproval = screen.getByRole('button', {+ name: 'share.chat.collapse Approval',+ })+ await user.click(collapseApproval)+ expect(collapseApproval).toHaveAttribute('aria-expanded', 'false')expect(screen.getAllByTestId('submitted-field-values')).toHaveLength(1)})})