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(dify-ui): give the Combobox popup search one layout (#43774)

yyh3821d55fded8
diff --git a/packages/dify-ui/src/combobox/index.stories.tsx b/packages/dify-ui/src/combobox/index.stories.tsx
index 8260eb6ade7..5e14fc361b2 100644
--- a/packages/dify-ui/src/combobox/index.stories.tsx
+++ b/packages/dify-ui/src/combobox/index.stories.tsx
@@ -356,19 +356,13 @@ const renderVirtualizedOptionItem = (option: Option, index: number, itemCount: n
function PopupSearchInput({ label, placeholder }: { label: string; placeholder: string }) {
return (
- <div className="p-1 pb-0">
- <ComboboxInputGroup className="h-8 min-h-8 px-2">
- <span
- aria-hidden
- className="mr-0.5 i-ri-search-line size-4 shrink-0 text-components-input-text-placeholder"
- />
- <ComboboxInput
- aria-label={label}
- placeholder={`${placeholder}…`}
- className="block h-4.5 grow px-1 py-0 system-sm-regular text-components-input-text-filled"
- />
- </ComboboxInputGroup>
- </div>
+ <ComboboxInputGroup>
+ <span
+ aria-hidden
+ className="i-ri-search-line size-4 shrink-0 text-components-input-text-placeholder"
+ />
+ <ComboboxInput aria-label={label} placeholder={`${placeholder}…`} />
+ </ComboboxInputGroup>
)
}
diff --git a/packages/dify-ui/src/combobox/index.tsx b/packages/dify-ui/src/combobox/index.tsx
index 80e25b46982..cb699ca3510 100644
--- a/packages/dify-ui/src/combobox/index.tsx
+++ b/packages/dify-ui/src/combobox/index.tsx
@@ -108,18 +108,30 @@ function ComboboxTrigger({ className, type = 'button', ...props }: ComboboxTrigg
)
}
-const comboboxInputGroupVariants = cva([textControlGroupClassName, 'group/combobox items-center'], {
- variants: {
- size: {
- small: 'min-h-6 rounded-md',
- medium: 'min-h-8 rounded-lg',
- large: 'min-h-9 rounded-[10px]',
+const comboboxInputGroupVariants = cva(
+ [
+ textControlGroupClassName,
+ 'group/combobox items-center',
+ // Inside the popup the group is the search box: it lines up with the options on 4px gutters,
+ // hosts an inline icon, and takes over the horizontal padding from its input and controls.
+ // The popup marks itself with a data attribute because a `role="dialog"` ancestor could also be
+ // a Dialog hosting a field anchor.
+ 'in-data-dify-combobox-popup:mx-1 in-data-dify-combobox-popup:mt-1 in-data-dify-combobox-popup:w-auto in-data-dify-combobox-popup:gap-0.5 in-data-dify-combobox-popup:px-2',
+ 'in-data-dify-combobox-popup:[&>button]:me-0 in-data-dify-combobox-popup:[&>input]:px-1',
+ ],
+ {
+ variants: {
+ size: {
+ small: 'min-h-6 rounded-md',
+ medium: 'min-h-8 rounded-lg',
+ large: 'min-h-9 rounded-[10px]',
+ },
+ },
+ defaultVariants: {
+ size: 'medium',
},
},
- defaultVariants: {
- size: 'medium',
- },
-})
+)
type ComboboxInputGroupProps = BaseCombobox.InputGroup.Props &
VariantProps<typeof comboboxInputGroupVariants>
@@ -297,6 +309,7 @@ type ComboboxPopupProps = BaseCombobox.Popup.Props
function ComboboxPopup({ className, ...props }: ComboboxPopupProps) {
return (
<BaseCombobox.Popup
+ data-dify-combobox-popup=""
className={(state) =>
cn(
comboboxPopupClassName,
diff --git a/web/app/components/api-key/dataset-scope-dialog.tsx b/web/app/components/api-key/dataset-scope-dialog.tsx
index 5b29f871deb..2a6309653a8 100644
--- a/web/app/components/api-key/dataset-scope-dialog.tsx
+++ b/web/app/components/api-key/dataset-scope-dialog.tsx
@@ -217,11 +217,9 @@ export function DatasetScopeDialog({
aria-label={searchLabel}
className="w-[min(20rem,var(--available-width))]"
>
- <div className="p-1 pb-0">
- <ComboboxInputGroup>
- <ComboboxInput aria-label={searchLabel} placeholder={searchLabel} />
- </ComboboxInputGroup>
- </div>
+ <ComboboxInputGroup>
+ <ComboboxInput aria-label={searchLabel} placeholder={searchLabel} />
+ </ComboboxInputGroup>
<ComboboxStatus>
{isLoading ? t(($) => $.loading, { ns: 'common' }) : null}
</ComboboxStatus>
diff --git a/web/app/components/apps/creators-filter.tsx b/web/app/components/apps/creators-filter.tsx
index 5cf75c81daf..f4da792a6eb 100644
--- a/web/app/components/apps/creators-filter.tsx
+++ b/web/app/components/apps/creators-filter.tsx
@@ -4,6 +4,7 @@ import { Avatar } from '@langgenius/dify-ui/avatar'
import { cn } from '@langgenius/dify-ui/cn'
import {
Combobox,
+ ComboboxEmpty,
ComboboxInput,
ComboboxInputGroup,
ComboboxItem,
@@ -86,6 +87,7 @@ const CreatorsFilter = ({ value, onChange }: CreatorsFilterProps) => {
.filter((creator): creator is CreatorOption => Boolean(creator))
}, [creatorMap, value])
+ // Clears the query only. `ComboboxClear` would clear the selected creators in `multiple` mode.
const clearCreatorQuery = useCallback(() => {
setKeywords('')
searchInputRef.current?.focus()
@@ -172,34 +174,31 @@ const CreatorsFilter = ({ value, onChange }: CreatorsFilterProps) => {
aria-label={t(($) => $['studio.filters.creators'], { ns: 'app' })}
className="w-[min(280px,var(--available-width))] min-w-[min(var(--anchor-width),var(--available-width))] bg-components-panel-bg-blur text-sm text-text-secondary backdrop-blur-[5px]"
>
- <div className="p-2 pb-1">
- <ComboboxInputGroup className="h-8 min-h-8 px-2">
- <ComboboxInput
- ref={searchInputRef}
- type="search"
- name="creator-query"
- enterKeyHint="search"
- aria-label={t(($) => $['studio.filters.searchCreators'], { ns: 'app' })}
- className="block h-4.5 grow px-1 py-0 [&::-webkit-search-cancel-button]:appearance-none [&::-webkit-search-decoration]:appearance-none"
- placeholder={t(($) => $['studio.filters.searchCreators'], { ns: 'app' })}
- />
- <span
- aria-hidden
- className="order-first me-0.5 i-ri-search-line size-4 shrink-0 text-components-input-text-placeholder"
- />
- {!!keywords && (
- <IconButton
- size="sm"
- aria-label={t(($) => $['operation.clear'], { ns: 'common' })}
- className="me-0 shrink-0 text-text-quaternary hover:bg-transparent hover:text-text-tertiary focus-visible:bg-components-input-bg-hover focus-visible:ring-inset"
- onClick={clearCreatorQuery}
- >
- <span aria-hidden className="i-ri-close-circle-fill size-4" />
- </IconButton>
- )}
- </ComboboxInputGroup>
- </div>
- <ComboboxList<CreatorOption> className="max-h-60 px-1 pt-0 pb-1">
+ <ComboboxInputGroup>
+ <span
+ aria-hidden
+ className="i-ri-search-line size-4 shrink-0 text-components-input-text-placeholder"
+ />
+ <ComboboxInput
+ ref={searchInputRef}
+ name="creator-query"
+ enterKeyHint="search"
+ aria-label={t(($) => $['studio.filters.searchCreators'], { ns: 'app' })}
+ placeholder={t(($) => $['studio.filters.searchCreators'], { ns: 'app' })}
+ />
+ {!!keywords && (
+ <IconButton
+ size="sm"
+ aria-label={t(($) => $['operation.clear'], { ns: 'common' })}
+ className="shrink-0 text-text-quaternary hover:bg-transparent hover:text-text-tertiary focus-visible:bg-components-input-bg-hover focus-visible:ring-inset"
+ onClick={clearCreatorQuery}
+ >
+ <span aria-hidden className="i-ri-close-circle-fill size-4" />
+ </IconButton>
+ )}
+ </ComboboxInputGroup>
+ <ComboboxEmpty>{t(($) => $.noData, { ns: 'common' })}</ComboboxEmpty>
+ <ComboboxList<CreatorOption> className="max-h-60">
{(creator) => (
<ComboboxItem<string>
key={creator.id}
diff --git a/web/app/components/datasets/common/document-picker/document-list.tsx b/web/app/components/datasets/common/document-picker/document-list.tsx
index 4275c10285f..184272e7ce7 100644
--- a/web/app/components/datasets/common/document-picker/document-list.tsx
+++ b/web/app/components/datasets/common/document-picker/document-list.tsx
@@ -20,7 +20,7 @@ function getDocumentExtension(document: SimpleDocumentDetail) {
export default function DocumentList({ className }: Props) {
return (
- <ComboboxList<SimpleDocumentDetail> className={cn('max-h-[calc(100vh-120px)] p-0', className)}>
+ <ComboboxList<SimpleDocumentDetail> className={cn('max-h-[calc(100vh-120px)]', className)}>
{(item) => {
const extension = getDocumentExtension(item)
return (
diff --git a/web/app/components/datasets/common/document-picker/index.tsx b/web/app/components/datasets/common/document-picker/index.tsx
index d4d7481dfc8..46531e7a5bb 100644
--- a/web/app/components/datasets/common/document-picker/index.tsx
+++ b/web/app/components/datasets/common/document-picker/index.tsx
@@ -162,20 +162,19 @@ export function DocumentPicker({ datasetId, value, parentMode, onChange }: Props
<ComboboxPositioner placement="bottom-start" sideOffset={0}>
<ComboboxPopup
aria-label={t(($) => $['operation.search'], { ns: 'common' })}
- className="w-90 rounded-xl border-[0.5px] border-components-panel-border bg-components-panel-bg-blur p-2 shadow-lg backdrop-blur-[5px]"
+ className="w-90 rounded-xl border-[0.5px] border-components-panel-border bg-components-panel-bg-blur shadow-lg backdrop-blur-[5px]"
>
- <ComboboxInputGroup className="h-8 min-h-8 px-2">
+ <ComboboxInputGroup>
<span
- className="mr-0.5 i-ri-search-line size-4 shrink-0 text-text-tertiary"
+ className="i-ri-search-line size-4 shrink-0 text-text-tertiary"
aria-hidden="true"
/>
<ComboboxInput
aria-label={t(($) => $['operation.search'], { ns: 'common' })}
placeholder={t(($) => $['operation.search'], { ns: 'common' })}
- className="block h-4.5 grow px-1 py-0 text-[13px] text-text-primary"
/>
</ComboboxInputGroup>
- <DocumentList className="mt-2 data-empty:mt-0" />
+ <DocumentList />
<ComboboxEmpty className="p-0">
{data && (
<div className="mt-2 flex h-25 w-full items-center justify-center px-3 py-2 system-sm-regular text-text-tertiary">
diff --git a/web/app/components/plugins/plugin-detail-panel/app-selector/app-picker.tsx b/web/app/components/plugins/plugin-detail-panel/app-selector/app-picker.tsx
index fe2a91f05c3..2593df7a516 100644
--- a/web/app/components/plugins/plugin-detail-panel/app-selector/app-picker.tsx
+++ b/web/app/components/plugins/plugin-detail-panel/app-selector/app-picker.tsx
@@ -157,34 +157,31 @@ export function AppPicker({
className="border-0 bg-transparent p-0 shadow-none backdrop-blur-none"
>
<div className="relative flex max-h-100 min-h-20 w-89 flex-col rounded-xl border-[0.5px] border-components-panel-border bg-components-panel-bg-blur shadow-lg backdrop-blur-xs">
- <div className="p-2 pb-1">
- <ComboboxInputGroup className="h-8 min-h-8 px-2">
- <span
- className="mr-0.5 i-ri-search-line size-4 shrink-0 text-text-tertiary"
- aria-hidden="true"
- />
- <ComboboxInput
- ref={inputRef}
- aria-label={t(($) => $['appSelector.placeholder'], { ns: 'app' })}
- placeholder={t(($) => $['appSelector.placeholder'], { ns: 'app' })}
- className="block h-4.5 grow px-1 py-0 text-[13px] text-text-primary"
- />
- {searchText && (
- <IconButton
- size="xs"
- aria-label={t(($) => $['operation.clear'], { ns: 'common' })}
- className="ml-1.5 size-3.5 shrink-0 rounded-none text-text-quaternary hover:bg-transparent hover:text-text-quaternary focus-visible:ring-1 focus-visible:ring-components-input-border-active"
- onClick={handleClearSearch}
- onMouseDown={(event) => event.preventDefault()}
- >
- <span
- className="i-custom-vender-solid-general-x-circle size-3.5"
- aria-hidden="true"
- />
- </IconButton>
- )}
- </ComboboxInputGroup>
- </div>
+ <ComboboxInputGroup>
+ <span
+ className="i-ri-search-line size-4 shrink-0 text-text-tertiary"
+ aria-hidden="true"
+ />
+ <ComboboxInput
+ ref={inputRef}
+ aria-label={t(($) => $['appSelector.placeholder'], { ns: 'app' })}
+ placeholder={t(($) => $['appSelector.placeholder'], { ns: 'app' })}
+ />
+ {searchText && (
+ <IconButton
+ size="xs"
+ aria-label={t(($) => $['operation.clear'], { ns: 'common' })}
+ className="ml-1.5 size-3.5 shrink-0 rounded-none text-text-quaternary hover:bg-transparent hover:text-text-quaternary focus-visible:ring-1 focus-visible:ring-components-input-border-active"
+ onClick={handleClearSearch}
+ onMouseDown={(event) => event.preventDefault()}
+ >
+ <span
+ className="i-custom-vender-solid-general-x-circle size-3.5"
+ aria-hidden="true"
+ />
+ </IconButton>
+ )}
+ </ComboboxInputGroup>
<ScrollArea className="min-h-0 flex-1 overflow-hidden">
<ScrollAreaViewport
role="region"
diff --git a/web/features/agent-v2/agent-detail/logs/components/source-picker.tsx b/web/features/agent-v2/agent-detail/logs/components/source-picker.tsx
index 2365b35722f..9d817b252e6 100644
--- a/web/features/agent-v2/agent-detail/logs/components/source-picker.tsx
+++ b/web/features/agent-v2/agent-detail/logs/components/source-picker.tsx
@@ -119,19 +119,16 @@ export function AgentLogSourcePicker({
aria-label={t(($) => $['agentDetail.logs.filters.source.label'])}
className="w-80 max-w-[calc(100vw-1rem)] p-0"
>
- <div className="p-2 pb-1">
- <ComboboxInputGroup className="h-8 min-h-8 px-2">
- <span
- aria-hidden
- className="mr-0.5 i-ri-search-line size-4 shrink-0 text-components-input-text-placeholder"
- />
- <ComboboxInput
- aria-label={t(($) => $['agentDetail.logs.filters.source.searchLabel'])}
- placeholder={t(($) => $['agentDetail.logs.filters.source.searchPlaceholder'])}
- className="block h-4.5 grow px-1 py-0 system-sm-regular text-components-input-text-filled"
- />
- </ComboboxInputGroup>
- </div>
+ <ComboboxInputGroup>
+ <span
+ aria-hidden
+ className="i-ri-search-line size-4 shrink-0 text-components-input-text-placeholder"
+ />
+ <ComboboxInput
+ aria-label={t(($) => $['agentDetail.logs.filters.source.searchLabel'])}
+ placeholder={t(($) => $['agentDetail.logs.filters.source.searchPlaceholder'])}
+ />
+ </ComboboxInputGroup>
<div
className={cn(
isLoading || isError
@@ -153,7 +150,7 @@ export function AgentLogSourcePicker({
)}
</div>
{!isLoading && !isError && (
- <ComboboxList<AgentLogSourceComboboxGroup> className="max-h-69 p-2 pt-1">
+ <ComboboxList<AgentLogSourceComboboxGroup> className="max-h-69">
{(group) => (
<ComboboxGroup<AgentLogSourceResponse> key={group.type} items={group.items}>
<ComboboxGroupLabel className="px-1 pt-2 pb-1">
diff --git a/web/features/tag-management/components/tag-search-content.tsx b/web/features/tag-management/components/tag-search-content.tsx
index 92c64fe94f7..ff94636a149 100644
--- a/web/features/tag-management/components/tag-search-content.tsx
+++ b/web/features/tag-management/components/tag-search-content.tsx
@@ -55,32 +55,26 @@ export const TagSearchContentView = ({
return (
<>
- <div className="p-2 pb-1">
- <ComboboxInputGroup className="border-divider-subtle bg-components-input-bg-normal">
- <span
- aria-hidden="true"
- className="ml-2 i-ri-search-line size-4 shrink-0 text-text-tertiary"
- />
- <ComboboxInput
- ref={inputRef}
- aria-label={placeholder}
- name={`tag-search-${type}`}
- placeholder={placeholder}
- className="pl-2"
- />
- {inputValue && (
- <IconButton
- size="sm"
- aria-label={t(($) => $['operation.clear'], { ns: 'common' })}
- className="mr-1.5 shrink-0 hover:bg-components-input-bg-hover focus-visible:bg-components-input-bg-hover"
- onClick={handleClearInput}
- onMouseDown={(event) => event.preventDefault()}
- >
- <span className="i-ri-close-line size-4" aria-hidden="true" />
- </IconButton>
- )}
- </ComboboxInputGroup>
- </div>
+ <ComboboxInputGroup>
+ <span aria-hidden="true" className="i-ri-search-line size-4 shrink-0 text-text-tertiary" />
+ <ComboboxInput
+ ref={inputRef}
+ aria-label={placeholder}
+ name={`tag-search-${type}`}
+ placeholder={placeholder}
+ />
+ {inputValue && (
+ <IconButton
+ size="sm"
+ aria-label={t(($) => $['operation.clear'], { ns: 'common' })}
+ className="shrink-0 hover:bg-components-input-bg-hover focus-visible:bg-components-input-bg-hover"
+ onClick={handleClearInput}
+ onMouseDown={(event) => event.preventDefault()}
+ >
+ <span className="i-ri-close-line size-4" aria-hidden="true" />
+ </IconButton>
+ )}
+ </ComboboxInputGroup>
<ComboboxList<TagComboboxItem> className="max-h-58">
{(tag) => {
if (isCreateTagOption(tag) && canManageTags) {