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.

refactor(web): let primitives own local interaction state (#42633)

yyhbf100beb9711
diff --git a/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/overview/tracing/config-button.tsx b/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/overview/tracing/config-button.tsx
index 6521fcdf73d..8b99b88d776 100644
--- a/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/overview/tracing/config-button.tsx
+++ b/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/overview/tracing/config-button.tsx
@@ -4,7 +4,6 @@ import type { PopupProps } from './config-popup'
import { cn } from '@langgenius/dify-ui/cn'
import { Popover, PopoverContent, PopoverTrigger } from '@langgenius/dify-ui/popover'
import * as React from 'react'
-import { useState } from 'react'
import ConfigPopup from './config-popup'
type Props = Readonly<{
@@ -16,12 +15,10 @@ type Props = Readonly<{
PopupProps
const ConfigBtn: FC<Props> = ({ className, hasConfigured, children, ...popupProps }) => {
- const [open, setOpen] = useState(false)
-
if (popupProps.readOnly && !hasConfigured) return null
return (
- <Popover open={open} onOpenChange={setOpen}>
+ <Popover>
<PopoverTrigger render={<div className={cn('select-none', className)}>{children}</div>} />
<PopoverContent
placement="bottom-end"
diff --git a/web/app/components/app/app-publisher/publish-with-multiple-model.tsx b/web/app/components/app/app-publisher/publish-with-multiple-model.tsx
index 7e3b216573e..3f94f9ab8a8 100644
--- a/web/app/components/app/app-publisher/publish-with-multiple-model.tsx
+++ b/web/app/components/app/app-publisher/publish-with-multiple-model.tsx
@@ -13,7 +13,6 @@ import {
} from '@langgenius/dify-ui/dropdown-menu'
import { RiArrowDownSLine } from '@remixicon/react'
import { useQuery } from '@tanstack/react-query'
-import { useState } from 'react'
import { useTranslation } from 'react-i18next'
import { ModelTypeEnum } from '@/app/components/header/account-setting/model-provider-page/declarations'
import { useLanguage } from '@/app/components/header/account-setting/model-provider-page/hooks'
@@ -39,7 +38,6 @@ const PublishWithMultipleModel: FC<PublishWithMultipleModelProps> = ({
select: (response) => response.data,
}),
)
- const [open, setOpen] = useState(false)
const validModelConfigs: (ModelAndParameter & {
modelItem: ProviderModelWithStatusEntity
@@ -68,7 +66,7 @@ const PublishWithMultipleModel: FC<PublishWithMultipleModelProps> = ({
const triggerDisabled = disabled || !validModelConfigs.length
return (
- <DropdownMenu open={open} onOpenChange={setOpen}>
+ <DropdownMenu>
<DropdownMenuTrigger
disabled={triggerDisabled}
render={<Button variant="primary" disabled={triggerDisabled} className="w-full" />}
diff --git a/web/app/components/app/configuration/config-vision/param-config.tsx b/web/app/components/app/configuration/config-vision/param-config.tsx
index 34f7ad7f76b..215d1c48e67 100644
--- a/web/app/components/app/configuration/config-vision/param-config.tsx
+++ b/web/app/components/app/configuration/config-vision/param-config.tsx
@@ -3,16 +3,15 @@ import type { FC } from 'react'
import { Button } from '@langgenius/dify-ui/button'
import { Popover, PopoverContent, PopoverTitle, PopoverTrigger } from '@langgenius/dify-ui/popover'
import { RiSettings2Line } from '@remixicon/react'
-import { memo, useState } from 'react'
+import { memo } from 'react'
import { useTranslation } from 'react-i18next'
import ParamConfigContent from './param-config-content'
const ParamsConfig: FC = () => {
const { t } = useTranslation()
- const [open, setOpen] = useState(false)
return (
- <Popover open={open} onOpenChange={setOpen}>
+ <Popover>
<PopoverTrigger
render={
<Button variant="ghost" size="small">
diff --git a/web/app/components/app/log/model-info.tsx b/web/app/components/app/log/model-info.tsx
index 93ea73179f1..c360308475e 100644
--- a/web/app/components/app/log/model-info.tsx
+++ b/web/app/components/app/log/model-info.tsx
@@ -32,8 +32,6 @@ const ModelInfo: FC<Props> = ({ model }) => {
model: modelName,
})
- const [open, setOpen] = React.useState(false)
-
const getParamValue = (param: keyof typeof PARAM_MAP) => {
const value = model.completion_params?.[param] ?? '-'
if (param === 'stop') {
@@ -50,7 +48,7 @@ const ModelInfo: FC<Props> = ({ model }) => {
<ModelIcon className="size-5!" provider={currentProvider} modelName={currentModel?.model} />
<ModelName modelItem={currentModel} showMode />
</div>
- <Popover open={open} onOpenChange={setOpen}>
+ <Popover>
<div className="relative">
<PopoverTrigger
render={
diff --git a/web/app/components/app/type-selector/index.tsx b/web/app/components/app/type-selector/index.tsx
index 241c5d686f4..9ba994a42d4 100644
--- a/web/app/components/app/type-selector/index.tsx
+++ b/web/app/components/app/type-selector/index.tsx
@@ -7,7 +7,6 @@ import {
RiFilter3Line,
} from '@remixicon/react'
import * as React from 'react'
-import { useState } from 'react'
import { useTranslation } from 'react-i18next'
import {
BubbleTextMod,
@@ -31,7 +30,6 @@ const allTypes: AppModeEnum[] = [
]
const AppTypeSelector = ({ value, onChange }: AppSelectorProps) => {
- const [open, setOpen] = useState(false)
const { t } = useTranslation()
const triggerLabel =
value.length === 0
@@ -39,7 +37,7 @@ const AppTypeSelector = ({ value, onChange }: AppSelectorProps) => {
: value.map((type) => getAppTypeLabel(type, t)).join(', ')
return (
- <Popover open={open} onOpenChange={setOpen}>
+ <Popover>
<div className="relative">
<PopoverTrigger
aria-label={triggerLabel}
diff --git a/web/app/components/base/chat/chat-with-history/header-in-mobile.tsx b/web/app/components/base/chat/chat-with-history/header-in-mobile.tsx
index 39bff5e5008..d8b9b471eb6 100644
--- a/web/app/components/base/chat/chat-with-history/header-in-mobile.tsx
+++ b/web/app/components/base/chat/chat-with-history/header-in-mobile.tsx
@@ -82,12 +82,11 @@ const HeaderInMobile = () => {
},
[showRename, handleRenameConversation, handleCancelRename],
)
- const [showSidebar, setShowSidebar] = useState(false)
const [showChatSettings, setShowChatSettings] = useState(false)
return (
<>
- <Dialog open={showSidebar} onOpenChange={setShowSidebar}>
+ <Dialog>
<div className="flex shrink-0 items-center gap-1 bg-mask-top2bottom-gray-50-to-transparent px-2 py-3">
<DialogTrigger
render={
diff --git a/web/app/components/base/chat/chat/citation/popup.tsx b/web/app/components/base/chat/chat/citation/popup.tsx
index b605aaf446d..ebe5a75bb87 100644
--- a/web/app/components/base/chat/chat/citation/popup.tsx
+++ b/web/app/components/base/chat/chat/citation/popup.tsx
@@ -1,7 +1,7 @@
import type { FC, MouseEvent } from 'react'
import type { Resources } from './index'
import { Popover, PopoverContent, PopoverTrigger } from '@langgenius/dify-ui/popover'
-import { Fragment, useState } from 'react'
+import { Fragment } from 'react'
import { useTranslation } from 'react-i18next'
import FileIcon from '@/app/components/base/file-icon'
import Link from '@/next/link'
@@ -17,7 +17,6 @@ type PopupProps = {
const Popup: FC<PopupProps> = ({ data, showHitInfo = false }) => {
const { t } = useTranslation()
- const [open, setOpen] = useState(false)
const fileType =
data.dataSourceType !== 'notion' ? /\.([^.]*)$/.exec(data.documentName)?.[1] || '' : 'notion'
@@ -37,7 +36,7 @@ const Popup: FC<PopupProps> = ({ data, showHitInfo = false }) => {
}
return (
- <Popover open={open} onOpenChange={setOpen}>
+ <Popover>
<PopoverTrigger
nativeButton={false}
render={
diff --git a/web/app/components/base/form/components/field/upload-method.tsx b/web/app/components/base/form/components/field/upload-method.tsx
index fa2c102f5b9..b086e532342 100644
--- a/web/app/components/base/form/components/field/upload-method.tsx
+++ b/web/app/components/base/form/components/field/upload-method.tsx
@@ -89,8 +89,7 @@ const UploadMethodField = ({ label, labelOptions, className }: UploadMethodField
value={option.value}
className={cn(
'flex h-8 w-full cursor-default items-center justify-center rounded-md border border-components-option-card-option-border bg-components-option-card-option-bg px-2 system-sm-regular text-text-secondary focus-visible:ring-2 focus-visible:ring-state-accent-solid focus-visible:outline-hidden data-checked:border-[1.5px] data-checked:border-components-option-card-option-selected-border data-checked:bg-components-option-card-option-selected-bg data-checked:shadow-xs',
- selectedMethod !== option.value &&
- 'cursor-pointer hover:border-components-option-card-option-border-hover hover:bg-components-option-card-option-bg-hover hover:shadow-xs',
+ 'data-unchecked:cursor-pointer data-unchecked:hover:border-components-option-card-option-border-hover data-unchecked:hover:bg-components-option-card-option-bg-hover data-unchecked:hover:shadow-xs',
)}
>
<span>{option.label}</span>
diff --git a/web/app/components/datasets/extra-info/service-api/index.tsx b/web/app/components/datasets/extra-info/service-api/index.tsx
index 199c3669d36..feffaf418cf 100644
--- a/web/app/components/datasets/extra-info/service-api/index.tsx
+++ b/web/app/components/datasets/extra-info/service-api/index.tsx
@@ -15,14 +15,13 @@ type ServiceApiProps = {
export function ServiceApi({ apiBaseUrl }: ServiceApiProps) {
const { t } = useTranslation()
- const [popoverOpen, setPopoverOpen] = useState(false)
const [apiKeyModalOpen, setApiKeyModalOpen] = useState(false)
const workspacePermissionKeys = useAtomValue(workspacePermissionKeysAtom)
const canManageApiKey = hasPermission(workspacePermissionKeys, 'dataset.api_key.manage')
return (
<div className="flex items-center">
- <Popover open={popoverOpen} onOpenChange={setPopoverOpen}>
+ <Popover>
<PopoverTrigger
render={(props) => (
<button
diff --git a/web/app/components/header/account-dropdown/index.tsx b/web/app/components/header/account-dropdown/index.tsx
index ee5945385b0..52d5adace3f 100644
--- a/web/app/components/header/account-dropdown/index.tsx
+++ b/web/app/components/header/account-dropdown/index.tsx
@@ -6,7 +6,7 @@ import {
DropdownMenuContent,
DropdownMenuTrigger,
} from '@langgenius/dify-ui/dropdown-menu'
-import { useState, useSyncExternalStore } from 'react'
+import { useSyncExternalStore } from 'react'
import { useTranslation } from 'react-i18next'
import { resetUser } from '@/app/components/base/amplitude/utils'
import { useRouter } from '@/next/navigation'
@@ -26,7 +26,6 @@ const getServerHydrationSnapshot = () => true
export default function AccountDropdown({ trigger }: AccountDropdownProps) {
const router = useRouter()
- const [isAccountMenuOpen, setIsAccountMenuOpen] = useState(false)
const isHydrating = useSyncExternalStore(
subscribeHydrationState,
getHydrationSnapshot,
@@ -46,7 +45,7 @@ export default function AccountDropdown({ trigger }: AccountDropdownProps) {
return (
<div>
- <DropdownMenu open={isAccountMenuOpen} onOpenChange={setIsAccountMenuOpen}>
+ <DropdownMenu>
<DropdownMenuTrigger
disabled={isHydrating}
render={trigger({
diff --git a/web/app/components/header/account-setting/model-provider-page/model-selector/popup-item.tsx b/web/app/components/header/account-setting/model-provider-page/model-selector/popup-item.tsx
index 1dd68ba7ff1..84663a7bc50 100644
--- a/web/app/components/header/account-setting/model-provider-page/model-selector/popup-item.tsx
+++ b/web/app/components/header/account-setting/model-provider-page/model-selector/popup-item.tsx
@@ -61,7 +61,6 @@ function PopupItem({
onSelect,
onHide,
}: PopupItemProps) {
- const [modelsOpen, setModelsOpen] = useState(true)
const [dropdownOpen, setDropdownOpen] = useState(false)
const providerHeadingId = useId()
const { t } = useTranslation()
@@ -123,8 +122,7 @@ function PopupItem({
return (
<Collapsible
- open={modelsOpen}
- onOpenChange={setModelsOpen}
+ defaultOpen
className="mb-1"
render={<section aria-labelledby={providerHeadingId} />}
>
diff --git a/web/app/components/plugins/marketplace/home/catalog-languages-filter.tsx b/web/app/components/plugins/marketplace/home/catalog-languages-filter.tsx
index eae77708b2e..8db0c496593 100644
--- a/web/app/components/plugins/marketplace/home/catalog-languages-filter.tsx
+++ b/web/app/components/plugins/marketplace/home/catalog-languages-filter.tsx
@@ -16,7 +16,6 @@ import { LANGUAGE_OPTIONS } from '../templates/template-language'
export default function CatalogLanguagesFilter() {
const { t } = useTranslation()
const [languages, setLanguages] = useFilterTemplateLanguages()
- const [open, setOpen] = useState(false)
const [searchText, setSearchText] = useState('')
const triggerRef = useRef<HTMLButtonElement>(null)
const shouldRestoreFocusRef = useRef(false)
@@ -55,7 +54,7 @@ export default function CatalogLanguagesFilter() {
}
return (
- <Popover open={open} onOpenChange={setOpen}>
+ <Popover>
<div className="relative inline-flex h-8 shrink-0 items-center">
<PopoverTrigger
render={
diff --git a/web/app/components/plugins/marketplace/search-box/tags-filter.tsx b/web/app/components/plugins/marketplace/search-box/tags-filter.tsx
index fba271a5061..011fc405b6b 100644
--- a/web/app/components/plugins/marketplace/search-box/tags-filter.tsx
+++ b/web/app/components/plugins/marketplace/search-box/tags-filter.tsx
@@ -18,7 +18,6 @@ type TagsFilterProps = {
}
function TagsFilter({ tags, onTagsChange, usedInMarketplace = false }: TagsFilterProps) {
const { t } = useTranslation()
- const [open, setOpen] = useState(false)
const [searchText, setSearchText] = useState('')
const { tags: options, tagsMap } = useTags()
const filteredOptions = options.filter((option) =>
@@ -38,7 +37,7 @@ function TagsFilter({ tags, onTagsChange, usedInMarketplace = false }: TagsFilte
}
return (
- <Popover open={open} onOpenChange={setOpen}>
+ <Popover>
{usedInMarketplace && (
<MarketplaceTrigger
selectedTagsLength={selectedTagsLength}
diff --git a/web/app/components/plugins/plugin-detail-panel/app-selector/index.tsx b/web/app/components/plugins/plugin-detail-panel/app-selector/index.tsx
index f9271c971e2..b5a8f020f22 100644
--- a/web/app/components/plugins/plugin-detail-panel/app-selector/index.tsx
+++ b/web/app/components/plugins/plugin-detail-panel/app-selector/index.tsx
@@ -29,7 +29,6 @@ type AppSelectorProps = {
export function AppSelector({ value, disabled, offset = 4, onSelect }: AppSelectorProps) {
const { t } = useTranslation()
- const [isShow, setIsShow] = useState(false)
const [isShowChooseApp, setIsShowChooseApp] = useState(false)
const [searchText, setSearchText] = useState('')
@@ -114,7 +113,7 @@ export function AppSelector({ value, disabled, offset = 4, onSelect }: AppSelect
)
return (
- <Popover open={isShow} onOpenChange={setIsShow}>
+ <Popover>
<PopoverTrigger
aria-label={t(($) => $['appSelector.label'], { ns: 'app' })}
disabled={disabled}
diff --git a/web/app/components/plugins/plugin-page/filter-management/category-filter.tsx b/web/app/components/plugins/plugin-page/filter-management/category-filter.tsx
index 0270adae7dd..c0dac5e95e4 100644
--- a/web/app/components/plugins/plugin-page/filter-management/category-filter.tsx
+++ b/web/app/components/plugins/plugin-page/filter-management/category-filter.tsx
@@ -16,7 +16,6 @@ type CategoriesFilterProps = {
}
const CategoriesFilter = ({ value, onChange }: CategoriesFilterProps) => {
const { t } = useTranslation()
- const [open, setOpen] = useState(false)
const [searchText, setSearchText] = useState('')
const searchLabel = t(($) => $.searchCategories, { ns: 'plugin' })
const { categories: options, categoriesMap } = useCategories()
@@ -26,7 +25,7 @@ const CategoriesFilter = ({ value, onChange }: CategoriesFilterProps) => {
const selectedTagsLength = value.length
return (
- <Popover open={open} onOpenChange={setOpen}>
+ <Popover>
<PopoverTrigger
nativeButton={false}
render={
diff --git a/web/app/components/plugins/plugin-page/filter-management/tag-filter.tsx b/web/app/components/plugins/plugin-page/filter-management/tag-filter.tsx
index 64c6afe91db..33e22edc880 100644
--- a/web/app/components/plugins/plugin-page/filter-management/tag-filter.tsx
+++ b/web/app/components/plugins/plugin-page/filter-management/tag-filter.tsx
@@ -15,7 +15,6 @@ type TagsFilterProps = {
}
const TagsFilter = ({ value, onChange }: TagsFilterProps) => {
const { t } = useTranslation()
- const [open, setOpen] = useState(false)
const [searchText, setSearchText] = useState('')
const { tags: options, getTagLabel } = useTags()
const filteredOptions = options.filter((option) =>
@@ -24,7 +23,7 @@ const TagsFilter = ({ value, onChange }: TagsFilterProps) => {
const selectedTagsLength = value.length
return (
- <Popover open={open} onOpenChange={setOpen}>
+ <Popover>
<PopoverTrigger
nativeButton={false}
render={
diff --git a/web/app/components/tools/labels/filter.tsx b/web/app/components/tools/labels/filter.tsx
index dfc458d5a5b..c246b0d80a4 100644
--- a/web/app/components/tools/labels/filter.tsx
+++ b/web/app/components/tools/labels/filter.tsx
@@ -17,10 +17,7 @@ type LabelFilterProps = {
}
const LabelFilter: FC<LabelFilterProps> = ({ value, onChange }) => {
const { t } = useTranslation()
- const [open, setOpen] = useState(false)
-
const { tags: labelList } = useTags()
-
const [keywords, setKeywords] = useState('')
const filteredLabelList = useMemo(() => {
@@ -37,7 +34,7 @@ const LabelFilter: FC<LabelFilterProps> = ({ value, onChange }) => {
}
return (
- <Popover open={open} onOpenChange={setOpen}>
+ <Popover>
<div className="relative">
<PopoverTrigger
className={cn(
diff --git a/web/app/components/tools/labels/selector.tsx b/web/app/components/tools/labels/selector.tsx
index 9e7501195ad..7595ff15312 100644
--- a/web/app/components/tools/labels/selector.tsx
+++ b/web/app/components/tools/labels/selector.tsx
@@ -16,10 +16,7 @@ type LabelSelectorProps = {
function LabelSelector({ value, onChange }: LabelSelectorProps) {
const { t } = useTranslation()
- const [open, setOpen] = useState(false)
-
const { tags: labelList } = useTags()
-
const [keywords, setKeywords] = useState('')
const debouncedKeywords = useDebouncedValue(keywords, 500)
const searchKeywords = keywords ? debouncedKeywords : ''
@@ -28,7 +25,7 @@ function LabelSelector({ value, onChange }: LabelSelectorProps) {
const selectedLabels = value.map((v) => labelList.find((l) => l.name === v)?.label).join(', ')
return (
- <Popover open={open} onOpenChange={setOpen}>
+ <Popover>
<div className="relative">
<PopoverTrigger
className={cn(
diff --git a/web/app/components/workflow/block-selector/snippets/snippet-tags-filter.tsx b/web/app/components/workflow/block-selector/snippets/snippet-tags-filter.tsx
index dc87e69d8f1..7c409e54d5c 100644
--- a/web/app/components/workflow/block-selector/snippets/snippet-tags-filter.tsx
+++ b/web/app/components/workflow/block-selector/snippets/snippet-tags-filter.tsx
@@ -17,7 +17,6 @@ type SnippetTagsFilterProps = {
const SnippetTagsFilter = ({ embedded = false, value, onChange }: SnippetTagsFilterProps) => {
const { t } = useTranslation()
- const [open, setOpen] = useState(false)
const [searchText, setSearchText] = useState('')
const { data: tagList = [] } = useQuery(
@@ -46,12 +45,11 @@ const SnippetTagsFilter = ({ embedded = false, value, onChange }: SnippetTagsFil
? selectedTags.map((tag) => tag.name).join(', ')
: t(($) => $['tag.placeholder'], { ns: 'common' })
const handleOpenChange = (nextOpen: boolean) => {
- setOpen(nextOpen)
if (!nextOpen) setSearchText('')
}
return (
- <Popover open={open} onOpenChange={handleOpenChange}>
+ <Popover onOpenChange={handleOpenChange}>
<PopoverTrigger
render={
<Button
diff --git a/web/app/components/workflow/nodes/_base/components/file-upload-setting.tsx b/web/app/components/workflow/nodes/_base/components/file-upload-setting.tsx
index 558cfba4db5..face9c3e887 100644
--- a/web/app/components/workflow/nodes/_base/components/file-upload-setting.tsx
+++ b/web/app/components/workflow/nodes/_base/components/file-upload-setting.tsx
@@ -192,8 +192,7 @@ const FileUploadSetting: FC<Props> = ({
value={method.value}
className={cn(
'flex h-8 w-full cursor-default items-center justify-center rounded-md border border-components-option-card-option-border bg-components-option-card-option-bg px-2 system-sm-regular text-text-secondary focus-visible:ring-2 focus-visible:ring-state-accent-solid focus-visible:outline-hidden data-checked:border-[1.5px] data-checked:border-components-option-card-option-selected-border data-checked:bg-components-option-card-option-selected-bg data-checked:shadow-xs',
- selectedMethod !== method.value &&
- 'cursor-pointer hover:border-components-option-card-option-border-hover hover:bg-components-option-card-option-bg-hover hover:shadow-xs',
+ 'data-unchecked:cursor-pointer data-unchecked:hover:border-components-option-card-option-border-hover data-unchecked:hover:bg-components-option-card-option-bg-hover data-unchecked:hover:shadow-xs',
)}
>
<span>{method.label}</span>
diff --git a/web/app/components/workflow/nodes/assigner/components/operation-selector.tsx b/web/app/components/workflow/nodes/assigner/components/operation-selector.tsx
index b04b30d918c..64a072a0fd4 100644
--- a/web/app/components/workflow/nodes/assigner/components/operation-selector.tsx
+++ b/web/app/components/workflow/nodes/assigner/components/operation-selector.tsx
@@ -12,7 +12,6 @@ import {
DropdownMenuSeparator,
DropdownMenuTrigger,
} from '@langgenius/dify-ui/dropdown-menu'
-import { useState } from 'react'
import { useTranslation } from 'react-i18next'
import { getOperationItems, isOperationItem } from '../utils'
@@ -41,7 +40,6 @@ const OperationSelector: FC<OperationSelectorProps> = ({
writeModeTypesNum,
}) => {
const { t } = useTranslation()
- const [open, setOpen] = useState(false)
const items = getOperationItems(
assignedVarType,
@@ -53,7 +51,7 @@ const OperationSelector: FC<OperationSelectorProps> = ({
const selectedItem = items.find((item) => item.value === value)
return (
- <DropdownMenu open={open} onOpenChange={setOpen}>
+ <DropdownMenu>
<DropdownMenuTrigger
disabled={disabled}
className={cn(
diff --git a/web/app/components/workflow/nodes/human-input/components/delivery-method/method-selector.tsx b/web/app/components/workflow/nodes/human-input/components/delivery-method/method-selector.tsx
index 9fc9c72b033..1a67cba0063 100644
--- a/web/app/components/workflow/nodes/human-input/components/delivery-method/method-selector.tsx
+++ b/web/app/components/workflow/nodes/human-input/components/delivery-method/method-selector.tsx
@@ -6,7 +6,7 @@ import { cn } from '@langgenius/dify-ui/cn'
import { IconButton } from '@langgenius/dify-ui/icon-button'
import { Popover, PopoverContent, PopoverTrigger } from '@langgenius/dify-ui/popover'
import { useQuery, useSuspenseQuery } from '@tanstack/react-query'
-import { memo, useMemo, useState } from 'react'
+import { memo, useMemo } from 'react'
import { Trans, useTranslation } from 'react-i18next'
import { v4 as uuid4 } from 'uuid'
import Badge from '@/app/components/base/badge'
@@ -30,7 +30,6 @@ const MethodSelector: FC<MethodSelectorProps> = ({ data, onAdd, onShowUpgradeTip
...systemFeaturesQueryOptions(),
select: ({ deployment_edition }) => deployment_edition,
})
- const [open, setOpen] = useState(false)
const { data: humanInputEmailDeliveryEnabled } = useQuery(
consoleQuery.features.get.queryOptions({
select: (features) => features.human_input_email_delivery_enabled,
@@ -55,7 +54,7 @@ const MethodSelector: FC<MethodSelectorProps> = ({ data, onAdd, onShowUpgradeTip
}, [data, humanInputEmailDeliveryEnabled])
return (
- <Popover open={open} onOpenChange={setOpen}>
+ <Popover>
<PopoverTrigger
render={
<IconButton
diff --git a/web/app/components/workflow/nodes/if-else/components/condition-number-input.tsx b/web/app/components/workflow/nodes/if-else/components/condition-number-input.tsx
index 50e3bc84185..ef99e14071b 100644
--- a/web/app/components/workflow/nodes/if-else/components/condition-number-input.tsx
+++ b/web/app/components/workflow/nodes/if-else/components/condition-number-input.tsx
@@ -43,7 +43,6 @@ const ConditionNumberInput = ({
}: ConditionNumberInputProps) => {
const searchInputRef = useRef<HTMLInputElement>(null)
const { t } = useTranslation()
- const [numberVarTypeVisible, setNumberVarTypeVisible] = useState(false)
const [variableSelectorVisible, setVariableSelectorVisible] = useState(false)
const [isFocus, { setTrue: setFocus, setFalse: setBlur }] = useBoolean()
@@ -57,7 +56,7 @@ const ConditionNumberInput = ({
return (
<div className="flex cursor-pointer items-center">
- <DropdownMenu open={numberVarTypeVisible} onOpenChange={setNumberVarTypeVisible}>
+ <DropdownMenu>
<DropdownMenuTrigger render={<Button className="shrink-0" variant="ghost" size="small" />}>
{capitalize(numberVarType)}
<RiArrowDownSLine className="size-3.5" />
diff --git a/web/app/components/workflow/nodes/llm/components/json-schema-config-modal/visual-editor/edit-card/type-selector.tsx b/web/app/components/workflow/nodes/llm/components/json-schema-config-modal/visual-editor/edit-card/type-selector.tsx
index 69284b5d04f..a18b992a5cb 100644
--- a/web/app/components/workflow/nodes/llm/components/json-schema-config-modal/visual-editor/edit-card/type-selector.tsx
+++ b/web/app/components/workflow/nodes/llm/components/json-schema-config-modal/visual-editor/edit-card/type-selector.tsx
@@ -13,7 +13,6 @@ import {
SelectValue,
} from '@langgenius/dify-ui/select'
import { RiCheckLine } from '@remixicon/react'
-import { useState } from 'react'
export type TypeItem = {
value: Type | ArrayType
@@ -27,12 +26,8 @@ type TypeSelectorProps = {
}
const TypeSelector: FC<TypeSelectorProps> = ({ items, currentValue, onSelect }) => {
- const [open, setOpen] = useState(false)
-
return (
<Select<Type | ArrayType>
- open={open}
- onOpenChange={setOpen}
value={currentValue}
onValueChange={(nextValue) => {
const selected = items.find((item) => item.value === nextValue)
diff --git a/web/app/components/workflow/nodes/loop/components/condition-number-input.tsx b/web/app/components/workflow/nodes/loop/components/condition-number-input.tsx
index 50e3bc84185..ef99e14071b 100644
--- a/web/app/components/workflow/nodes/loop/components/condition-number-input.tsx
+++ b/web/app/components/workflow/nodes/loop/components/condition-number-input.tsx
@@ -43,7 +43,6 @@ const ConditionNumberInput = ({
}: ConditionNumberInputProps) => {
const searchInputRef = useRef<HTMLInputElement>(null)
const { t } = useTranslation()
- const [numberVarTypeVisible, setNumberVarTypeVisible] = useState(false)
const [variableSelectorVisible, setVariableSelectorVisible] = useState(false)
const [isFocus, { setTrue: setFocus, setFalse: setBlur }] = useBoolean()
@@ -57,7 +56,7 @@ const ConditionNumberInput = ({
return (
<div className="flex cursor-pointer items-center">
- <DropdownMenu open={numberVarTypeVisible} onOpenChange={setNumberVarTypeVisible}>
+ <DropdownMenu>
<DropdownMenuTrigger render={<Button className="shrink-0" variant="ghost" size="small" />}>
{capitalize(numberVarType)}
<RiArrowDownSLine className="size-3.5" />
diff --git a/web/app/components/workflow/panel/version-history-panel/filter/index.tsx b/web/app/components/workflow/panel/version-history-panel/filter/index.tsx
index 86cada87955..5f9bd665df6 100644
--- a/web/app/components/workflow/panel/version-history-panel/filter/index.tsx
+++ b/web/app/components/workflow/panel/version-history-panel/filter/index.tsx
@@ -4,7 +4,7 @@ import { Popover, PopoverContent, PopoverTrigger } from '@langgenius/dify-ui/pop
import { Separator } from '@langgenius/dify-ui/separator'
import { RiFilter3Line } from '@remixicon/react'
import * as React from 'react'
-import { useCallback, useState } from 'react'
+import { useCallback } from 'react'
import { WorkflowVersionFilterOptions } from '../../../types'
import FilterItem from './filter-item'
import FilterSwitch from './filter-switch'
@@ -23,7 +23,6 @@ const Filter: FC<FilterProps> = ({
onClickFilterItem,
handleSwitch,
}) => {
- const [open, setOpen] = useState(false)
const options = useFilterOptions()
const handleOnClick = useCallback(
@@ -36,7 +35,7 @@ const Filter: FC<FilterProps> = ({
const isFiltering = filterValue !== WorkflowVersionFilterOptions.all || isOnlyShowNamedVersions
return (
- <Popover open={open} onOpenChange={setOpen}>
+ <Popover>
<PopoverTrigger
nativeButton={false}
render={
diff --git a/web/app/components/workflow/run/agent-log/agent-log-nav-more.tsx b/web/app/components/workflow/run/agent-log/agent-log-nav-more.tsx
index 9647a5820f1..864048b6af3 100644
--- a/web/app/components/workflow/run/agent-log/agent-log-nav-more.tsx
+++ b/web/app/components/workflow/run/agent-log/agent-log-nav-more.tsx
@@ -6,7 +6,6 @@ import {
DropdownMenuTrigger,
} from '@langgenius/dify-ui/dropdown-menu'
import { IconButton } from '@langgenius/dify-ui/icon-button'
-import { useState } from 'react'
import { useTranslation } from 'react-i18next'
type AgentLogNavMoreProps = {
@@ -15,10 +14,9 @@ type AgentLogNavMoreProps = {
}
const AgentLogNavMore = ({ options, onShowAgentOrToolLog }: AgentLogNavMoreProps) => {
const { t } = useTranslation()
- const [open, setOpen] = useState(false)
return (
- <DropdownMenu open={open} onOpenChange={setOpen}>
+ <DropdownMenu>
<DropdownMenuTrigger
render={
<IconButton
diff --git a/web/features/agent-v2/agent-detail/configure/components/preview/versions-panel/filter.tsx b/web/features/agent-v2/agent-detail/configure/components/preview/versions-panel/filter.tsx
index 2486200b4d3..8dae66d64ad 100644
--- a/web/features/agent-v2/agent-detail/configure/components/preview/versions-panel/filter.tsx
+++ b/web/features/agent-v2/agent-detail/configure/components/preview/versions-panel/filter.tsx
@@ -2,7 +2,6 @@
import { cn } from '@langgenius/dify-ui/cn'
import { Popover, PopoverContent, PopoverTrigger } from '@langgenius/dify-ui/popover'
-import { useState } from 'react'
import { useTranslation } from 'react-i18next'
export type AgentVersionFilter = 'all' | 'onlyYours'
@@ -39,11 +38,10 @@ export function VersionFilter({
}) {
const { t } = useTranslation('agentV2')
const { t: tWorkflow } = useTranslation('workflow')
- const [open, setOpen] = useState(false)
const isFiltering = filterValue !== 'all'
return (
- <Popover open={open} onOpenChange={setOpen}>
+ <Popover>
<PopoverTrigger
nativeButton={false}
render={