Skip to content

armgit / dify

Public Imported from GitHub
0

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.

fix(web): use button for workflow debug close (#40274)

yyh6422ef2b57c5
diff --git a/oxlint-suppressions.json b/oxlint-suppressions.json
index 36e09b0c5a2..bda51f3b8c8 100644
--- a/oxlint-suppressions.json
+++ b/oxlint-suppressions.json
@@ -5035,14 +5035,6 @@
"count": 11
}
},
- "web/app/components/workflow/panel/debug-and-preview/index.tsx": {
- "jsx_a11y/click-events-have-key-events": {
- "count": 1
- },
- "jsx_a11y/no-static-element-interactions": {
- "count": 1
- }
- },
"web/app/components/workflow/panel/debug-and-preview/user-input.tsx": {
"jsx_a11y/no-autofocus": {
"count": 1
diff --git a/web/app/components/workflow/panel/debug-and-preview/__tests__/debug-and-preview.spec.tsx b/web/app/components/workflow/panel/debug-and-preview/__tests__/debug-and-preview.spec.tsx
index 8e1cf322c6e..7d1436bb69e 100644
--- a/web/app/components/workflow/panel/debug-and-preview/__tests__/debug-and-preview.spec.tsx
+++ b/web/app/components/workflow/panel/debug-and-preview/__tests__/debug-and-preview.spec.tsx
@@ -8,6 +8,7 @@ import DebugAndPreview from '../index'
const mockHandleRestart = vi.fn()
const mockHandleNodeCancelRunningStatus = vi.fn()
const mockHandleEdgeCancelRunningStatus = vi.fn()
+const mockHandleCancelDebugAndPreviewPanel = vi.fn()
vi.mock('reactflow', () => ({
useNodes: () => [
@@ -23,7 +24,7 @@ vi.mock('reactflow', () => ({
vi.mock('../../../hooks/use-workflow-panel-interactions', () => ({
useWorkflowInteractions: () => ({
- handleCancelDebugAndPreviewPanel: vi.fn(),
+ handleCancelDebugAndPreviewPanel: mockHandleCancelDebugAndPreviewPanel,
}),
}))
@@ -92,4 +93,22 @@ describe('DebugAndPreview', () => {
expect(toggle).toHaveAttribute('aria-pressed', 'false')
})
+
+ it('closes the panel through a named keyboard action', async () => {
+ const user = userEvent.setup()
+ renderWorkflowComponent(<DebugAndPreview />, {
+ initialStoreState: {
+ previewPanelWidth: 400,
+ },
+ })
+
+ const closeButton = screen.getByRole('button', { name: /operation\.close/ })
+ closeButton.focus()
+
+ expect(closeButton).toHaveFocus()
+
+ await user.keyboard('{Enter}')
+
+ expect(mockHandleCancelDebugAndPreviewPanel).toHaveBeenCalledTimes(1)
+ })
})
diff --git a/web/app/components/workflow/panel/debug-and-preview/index.tsx b/web/app/components/workflow/panel/debug-and-preview/index.tsx
index a6e5e3cd5e9..f402948e003 100644
--- a/web/app/components/workflow/panel/debug-and-preview/index.tsx
+++ b/web/app/components/workflow/panel/debug-and-preview/index.tsx
@@ -33,6 +33,7 @@ const DebugAndPreview = () => {
const startNode = nodes.find((node) => node.data.type === BlockEnum.Start)
const variables = startNode?.data.variables || []
const visibleVariables = variables
+ const closeLabel = t(($) => $['operation.close'], { ns: 'common' })
const restartLabel = t(($) => $['operation.refresh'], { ns: 'common' })
const userInputFieldLabel = t(($) => $['panel.userInputField'], { ns: 'workflow' })
@@ -126,12 +127,14 @@ const DebugAndPreview = () => {
</div>
)}
<div className="mx-3 h-3.5 w-px bg-divider-regular"></div>
- <div
- className="flex size-6 cursor-pointer items-center justify-center"
+ <button
+ type="button"
+ aria-label={closeLabel}
+ className="flex size-6 cursor-pointer appearance-none items-center justify-center rounded-md border-0 bg-transparent p-0 focus-visible:ring-2 focus-visible:ring-state-accent-solid focus-visible:outline-hidden"
onClick={handleCancelDebugAndPreviewPanel}
>
- <RiCloseLine className="size-4 text-text-tertiary" />
- </div>
+ <RiCloseLine aria-hidden="true" className="size-4 text-text-tertiary" />
+ </button>
</div>
</div>
<div className="grow overflow-y-auto rounded-b-2xl">