From 6c089cab6671b23c4017c8cf51d44f9b188e7529 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9D=9E=E6=B3=95=E6=93=8D=E4=BD=9C?= Date: Mon, 27 Apr 2026 13:27:19 +0800 Subject: [PATCH] fix(web): migrate variable type selector overlay (#35590) Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: yyh <92089059+lyzno1@users.noreply.github.com> --- eslint-suppressions.json | 8 -- .../__tests__/variable-type-select.spec.tsx | 3 +- .../components/variable-type-select.tsx | 76 ++++++++++--------- 3 files changed, 42 insertions(+), 45 deletions(-) diff --git a/eslint-suppressions.json b/eslint-suppressions.json index b3c7a18fea..1e7a2662ed 100644 --- a/eslint-suppressions.json +++ b/eslint-suppressions.json @@ -5338,14 +5338,6 @@ "count": 2 } }, - "web/app/components/workflow/panel/chat-variable-panel/components/variable-type-select.tsx": { - "no-restricted-imports": { - "count": 1 - }, - "ts/no-explicit-any": { - "count": 4 - } - }, "web/app/components/workflow/panel/chat-variable-panel/type.ts": { "erasable-syntax-only/enums": { "count": 1 diff --git a/web/app/components/workflow/panel/chat-variable-panel/components/__tests__/variable-type-select.spec.tsx b/web/app/components/workflow/panel/chat-variable-panel/components/__tests__/variable-type-select.spec.tsx index 3a7df8a3bf..d0831c319c 100644 --- a/web/app/components/workflow/panel/chat-variable-panel/components/__tests__/variable-type-select.spec.tsx +++ b/web/app/components/workflow/panel/chat-variable-panel/components/__tests__/variable-type-select.spec.tsx @@ -36,8 +36,9 @@ describe('VariableTypeSelector', () => { await user.keyboard('{Escape}') await waitFor(() => { - expect(screen.queryByText('number')).not.toBeInTheDocument() + expect(screen.getByRole('combobox')).toHaveAttribute('aria-expanded', 'false') }) + expect(screen.queryByRole('listbox')).not.toBeInTheDocument() }) it('keeps the custom popup class in in-cell mode', async () => { diff --git a/web/app/components/workflow/panel/chat-variable-panel/components/variable-type-select.tsx b/web/app/components/workflow/panel/chat-variable-panel/components/variable-type-select.tsx index 94a0100de2..e1f776f3d5 100644 --- a/web/app/components/workflow/panel/chat-variable-panel/components/variable-type-select.tsx +++ b/web/app/components/workflow/panel/chat-variable-panel/components/variable-type-select.tsx @@ -1,38 +1,47 @@ 'use client' import { cn } from '@langgenius/dify-ui/cn' -import { RiArrowDownSLine, RiCheckLine } from '@remixicon/react' +import { Select, SelectContent, SelectItem, SelectItemIndicator, SelectItemText, SelectTrigger } from '@langgenius/dify-ui/select' import * as React from 'react' import { useState } from 'react' -import { - PortalToFollowElem, - PortalToFollowElemContent, - PortalToFollowElemTrigger, -} from '@/app/components/base/portal-to-follow-elem' -type Props = { +type Props = { inCell?: boolean - value?: any - list: any - onSelect: (value: any) => void + value?: T + list: readonly T[] + onSelect: (value: T) => void popupClassName?: string } -const VariableTypeSelector = ({ +const VariableTypeSelector = ({ inCell = false, value, list, onSelect, popupClassName, -}: Props) => { +}: Props) => { const [open, setOpen] = useState(false) + const handleValueChange = (nextValue: string | null) => { + if (!nextValue) + return + + const nextItem = list.find(item => item === nextValue) + if (!nextItem) + return + + onSelect(nextItem) + } + return ( - setOpen(v => !v)} - placement="bottom" + onOpenChange={setOpen} + onValueChange={handleValueChange} > - setOpen(v => !v)}> +
{value}
- +
- -
- {list.map((item: any) => ( -
{ - onSelect(item) - setOpen(false) - }} - > -
{item}
- {value === item && } -
- ))} -
-
-
+ + + {list.map(item => ( + + {item} + + + ))} + + ) }