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
refactor: let Dify UI list primitives own the search box and option layout (#43859)
yyh2683c0b14c44
diff --git a/packages/dify-ui/docs/selection.md b/packages/dify-ui/docs/selection.mdindex 167622ceadf..5fdf3989e60 100644--- a/packages/dify-ui/docs/selection.md+++ b/packages/dify-ui/docs/selection.md@@ -29,6 +29,13 @@ Autocomplete, Combobox, and Select popups use Base UI's `--anchor-width` and `--variables to follow their trigger while clamping to the viewport. Do not replace that sizing witha fixed width or an unclamped minimum width.+When a Combobox renders its input inside the popup, do not add a control that clears the typed+query. The query is per-open state that Base UI resets: choosing an item clears it in `multiple`+mode and closes the popup in single mode, and closing the popup (Escape, outside press) clears it.+A clear control there adds a second tab stop to the popup's focus loop and a second x that means+something other than `ComboboxClear`, which clears the selected value. Outside the popup, use+`ComboboxClear` or `AutocompleteClear`.+Use `Radio` for the default radio appearance. Use `RadioItem` when custom content itself is aradio item, and put `RadioControl` inside it for Dify UI's visual indicator. `RadioControl` is avisual part, not a standalone radio.diff --git a/packages/dify-ui/src/autocomplete/index.stories.tsx b/packages/dify-ui/src/autocomplete/index.stories.tsxindex b47cd73a9cb..7aabbd20741 100644--- a/packages/dify-ui/src/autocomplete/index.stories.tsx+++ b/packages/dify-ui/src/autocomplete/index.stories.tsx@@ -300,7 +300,7 @@ function SuggestionItem({ item, dense }: { item: Suggestion; dense?: boolean })<span className={cn(item.icon, 'size-4 shrink-0 text-text-tertiary')} aria-hidden="true" />)}<div className="flex min-w-0 grow flex-col">- <AutocompleteItemText className="px-0">{item.label}</AutocompleteItemText>+ <AutocompleteItemText>{item.label}</AutocompleteItemText>{!dense && item.description && (<span className="truncate system-xs-regular text-text-tertiary">{item.description}</span>)}@@ -330,7 +330,7 @@ function VirtualizedSuggestionItem({<span className={cn(item.icon, 'size-4 shrink-0 text-text-tertiary')} aria-hidden="true" />)}<div className="flex min-w-0 grow flex-col">- <AutocompleteItemText className="px-0">{item.label}</AutocompleteItemText>+ <AutocompleteItemText>{item.label}</AutocompleteItemText>{!dense && item.description && (<span className="truncate system-xs-regular text-text-tertiary">{item.description}</span>)}@@ -347,7 +347,7 @@ function VirtualizedSuggestionItem({function TagSuggestionItem({ item }: { item: Suggestion }) {return (<AutocompleteItem value={item}>- <AutocompleteItemText className="px-0">{item.label}</AutocompleteItemText>+ <AutocompleteItemText>{item.label}</AutocompleteItemText>{item.description && (<span className="ml-auto max-w-36 truncate system-xs-regular text-text-tertiary">{item.description}@@ -367,7 +367,7 @@ function BasicTagAutocomplete({ size = 'medium' }: { size?: 'small' | 'medium' |><AutocompleteInputGroup size={size}><span- className="ml-2 i-ri-search-line size-4 shrink-0 text-text-tertiary"+ className="i-ri-search-line size-4 shrink-0 text-components-input-text-placeholder"aria-hidden="true"/><AutocompleteInput@@ -417,11 +417,8 @@ function CommandPaletteList() {<AutocompleteList className="max-h-72 rounded-lg border border-divider-subtle bg-components-panel-bg p-1 shadow-xs">{groups.map((group, groupIndex) => (<AutocompleteGroup key={group.label} items={group.items}>- <AutocompleteGroupLabel- className={groupIndex > 0 ? 'mt-1 border-t border-divider-subtle pt-2' : undefined}- >- {group.label}- </AutocompleteGroupLabel>+ {groupIndex > 0 && <AutocompleteSeparator />}+ <AutocompleteGroupLabel>{group.label}</AutocompleteGroupLabel><AutocompleteCollection<Suggestion>>{(item) => (<AutocompleteItem key={item.value} value={item} className="grid grid-cols-[1fr_auto]">@@ -433,7 +430,7 @@ function CommandPaletteList() {/>)}<span className="min-w-0">- <AutocompleteItemText className="block px-0">{item.label}</AutocompleteItemText>+ <AutocompleteItemText className="block">{item.label}</AutocompleteItemText><span className="block truncate system-xs-regular text-text-tertiary">{item.description}</span>@@ -515,7 +512,7 @@ function AsyncSearchDemo() {><AutocompleteInputGroup><span- className="ml-2 i-ri-cloud-line size-4 shrink-0 text-text-tertiary"+ className="i-ri-cloud-line size-4 shrink-0 text-components-input-text-placeholder"aria-hidden="true"/><AutocompleteInput@@ -565,7 +562,7 @@ function VirtualizedSuggestionList({return (<divref={scrollRef}- className="max-h-[min(22rem,var(--available-height))] overflow-x-hidden overflow-y-auto overscroll-contain outline-hidden"+ className="max-h-[min(22rem,var(--available-height))] overflow-x-hidden overflow-y-auto overscroll-contain p-1 outline-hidden"><AutocompleteListclassName="relative max-h-none overflow-visible p-0"@@ -598,7 +595,7 @@ function VirtualizedStatus() {const filteredItems = useAutocompleteFilteredItems<Suggestion>()return (- <AutocompleteStatus className="border-b border-divider-subtle text-text-quaternary tabular-nums">+ <AutocompleteStatus>{filteredItems.length} matching suggestions. Selecting one only replaces the input text.</AutocompleteStatus>)@@ -647,7 +644,7 @@ function FuzzyMatchingDemo() {><AutocompleteInputGroup><span- className="ml-2 i-ri-sparkling-2-line size-4 shrink-0 text-text-tertiary"+ className="i-ri-sparkling-2-line size-4 shrink-0 text-components-input-text-placeholder"aria-hidden="true"/><AutocompleteInput@@ -670,7 +667,7 @@ function FuzzyMatchingDemo() {/>)}<div className="min-w-0 grow">- <AutocompleteItemText className="block px-0">+ <AutocompleteItemText className="block"><FuzzyHighlight text={item.label} query={value} /></AutocompleteItemText><span className="block truncate system-xs-regular text-text-tertiary">@@ -738,7 +735,7 @@ export const InlineAutocomplete: Story = {><AutocompleteInputGroup><span- className="ml-2 i-ri-text-snippet size-4 shrink-0 text-text-tertiary"+ className="i-ri-text-snippet size-4 shrink-0 text-components-input-text-placeholder"aria-hidden="true"/><AutocompleteInput@@ -774,7 +771,7 @@ export const GroupedSuggestions: Story = {><AutocompleteInputGroup><span- className="ml-2 i-ri-command-line size-4 shrink-0 text-text-tertiary"+ className="i-ri-command-line size-4 shrink-0 text-components-input-text-placeholder"aria-hidden="true"/><AutocompleteInput@@ -786,7 +783,7 @@ export const GroupedSuggestions: Story = {</AutocompleteInputGroup><AutocompletePortal><AutocompletePositioner>- <AutocompletePopup className="w-105">+ <AutocompletePopup><GroupedSuggestionList /><AutocompleteEmpty>No suggestion. Use the text as entered.</AutocompleteEmpty></AutocompletePopup>@@ -813,7 +810,7 @@ export const LimitResults: Story = {><AutocompleteInputGroup><span- className="ml-2 i-ri-tools-line size-4 shrink-0 text-text-tertiary"+ className="i-ri-tools-line size-4 shrink-0 text-components-input-text-placeholder"aria-hidden="true"/><AutocompleteInput@@ -825,8 +822,8 @@ export const LimitResults: Story = {</AutocompleteInputGroup><AutocompletePortal><AutocompletePositioner>- <AutocompletePopup className="w-105">- <AutocompleteStatus className="border-b border-divider-subtle">+ <AutocompletePopup>+ <AutocompleteStatus><LimitedStatus total={workflowSuggestions.length} /></AutocompleteStatus><AutocompleteList<Suggestion>>@@ -855,7 +852,7 @@ export const CommandPalette: Story = {><AutocompleteInputGroup className="mb-2"><span- className="ml-2 i-ri-search-line size-4 shrink-0 text-text-tertiary"+ className="i-ri-search-line size-4 shrink-0 text-components-input-text-placeholder"aria-hidden="true"/><AutocompleteInput@@ -888,7 +885,7 @@ function VirtualizedLongSuggestionsDemo() {><AutocompleteInputGroup><span- className="ml-2 i-ri-search-line size-4 shrink-0 text-text-tertiary"+ className="i-ri-search-line size-4 shrink-0 text-components-input-text-placeholder"aria-hidden="true"/><AutocompleteInput@@ -900,7 +897,7 @@ function VirtualizedLongSuggestionsDemo() {</AutocompleteInputGroup><AutocompletePortal><AutocompletePositioner>- <AutocompletePopup className="w-110 p-1">+ <AutocompletePopup><VirtualizedStatus /><VirtualizedSuggestionList virtualizerRef={virtualizerRef} /><AutocompleteEmpty>No suggestion. Free-form text is still valid.</AutocompleteEmpty>@@ -932,7 +929,7 @@ export const Empty: Story = {><AutocompleteInputGroup><span- className="ml-2 i-ri-search-line size-4 shrink-0 text-text-tertiary"+ className="i-ri-search-line size-4 shrink-0 text-components-input-text-placeholder"aria-hidden="true"/><AutocompleteInputdiff --git a/packages/dify-ui/src/autocomplete/index.tsx b/packages/dify-ui/src/autocomplete/index.tsxindex cc69d4b0fad..a7599c2e5e4 100644--- a/packages/dify-ui/src/autocomplete/index.tsx+++ b/packages/dify-ui/src/autocomplete/index.tsx@@ -79,19 +79,21 @@ const autocompleteListClassName = []const autocompleteItemClassName = [- 'mx-1 flex min-h-8 cursor-pointer select-none items-center gap-2 rounded-lg px-2 py-1.5 text-text-secondary outline-hidden',+ 'flex min-h-8 cursor-pointer select-none items-center gap-2 rounded-lg px-2 py-1.5 text-text-secondary outline-hidden','data-highlighted:bg-state-base-hover data-highlighted:text-text-primary','data-disabled:cursor-not-allowed data-disabled:opacity-30',]+// Same layout as `ComboboxInputGroup`: the group owns the horizontal padding and the gap, the input+// keeps a narrow inset, and the controls have no margins of their own.const autocompleteInputGroupVariants = cva(- [textControlGroupClassName, 'group/autocomplete items-center'],+ [textControlGroupClassName, 'group/autocomplete items-center gap-0.5'],{variants: {size: {- small: 'h-6 rounded-md',- medium: 'h-8 rounded-lg',- large: 'h-9 rounded-[10px]',+ small: 'min-h-6 rounded-md px-1',+ medium: 'min-h-8 rounded-lg px-2',+ large: 'min-h-9 rounded-[10px] px-3',},},defaultVariants: {@@ -120,17 +122,18 @@ function AutocompleteInputGroup({const autocompleteInputVariants = cva([- 'w-0 min-w-0 flex-1 appearance-none border-0 bg-transparent text-components-input-text-filled caret-primary-600 outline-hidden',+ 'w-0 min-w-0 flex-1 appearance-none border-0 bg-transparent px-1 text-components-input-text-filled caret-primary-600 outline-hidden','placeholder:text-components-input-text-placeholder','disabled:cursor-not-allowed disabled:text-components-input-text-filled-disabled disabled:placeholder:text-components-input-text-disabled','enabled:data-readonly:cursor-default',],{variants: {+ // Vertical padding fills the group's min height exactly, so the group never grows past it.size: {- small: 'px-2 py-1 system-xs-regular',- medium: 'px-3 py-1.75 system-sm-regular',- large: 'px-4 py-2 system-md-regular',+ small: 'py-0.75 system-xs-regular',+ medium: 'py-1.75 system-sm-regular',+ large: 'py-1.75 system-md-regular',},},defaultVariants: {@@ -172,9 +175,9 @@ const autocompleteControlVariants = cva({variants: {size: {- small: 'me-1 size-4',- medium: 'me-1.5 size-5',- large: 'me-2 size-5',+ small: 'size-4',+ medium: 'size-5',+ large: 'size-5',},},defaultVariants: {@@ -327,17 +330,19 @@ function AutocompleteItem<Value = unknown>({ className, ...props }: Autocompletetype AutocompleteItemTextProps = React.ComponentProps<'span'>function AutocompleteItemText({ className, ...props }: AutocompleteItemTextProps) {- return (- <span className={cn('min-w-0 grow truncate px-1 system-sm-medium', className)} {...props} />- )+ return <span className={cn('min-w-0 grow truncate system-sm-medium', className)} {...props} />}type AutocompleteGroupLabelProps = BaseAutocomplete.GroupLabel.Props+// The list's own padding supplies the rest of the inset, so the label text lines up with the+// item text.function AutocompleteGroupLabel({ className, ...props }: AutocompleteGroupLabelProps) {return (<BaseAutocomplete.GroupLabel- className={(state) => cn(floatingGroupLabelClassName, resolveClassName(className, state))}+ className={(state) =>+ cn(floatingGroupLabelClassName, 'px-2', resolveClassName(className, state))+ }{...props}/>)@@ -376,7 +381,10 @@ function AutocompleteStatus({ className, ...props }: AutocompleteStatusProps) {return (<BaseAutocomplete.StatusclassName={(state) =>- cn('px-3 py-2 system-sm-regular text-text-tertiary', resolveClassName(className, state))+ cn(+ 'px-3 py-2 system-sm-regular text-text-tertiary empty:p-0',+ resolveClassName(className, state),+ )}{...props}/>diff --git a/packages/dify-ui/src/combobox/index.stories.tsx b/packages/dify-ui/src/combobox/index.stories.tsxindex 5e14fc361b2..f05ed771607 100644--- a/packages/dify-ui/src/combobox/index.stories.tsx+++ b/packages/dify-ui/src/combobox/index.stories.tsx@@ -300,13 +300,8 @@ async function searchOptions(}const renderOptionItem = (option: Option) => (- <ComboboxItem- key={option.value}- value={option}- disabled={option.disabled}- className="h-auto min-h-8 py-1.5"- >- <ComboboxItemText className="flex items-center gap-2 px-0">+ <ComboboxItem key={option.value} value={option} disabled={option.disabled}>+ <ComboboxItemText className="flex items-center gap-2">{option.icon && (<span aria-hidden className={cn(option.icon, 'size-4 shrink-0 text-text-tertiary')} />)}@@ -337,9 +332,8 @@ const renderVirtualizedOptionItem = (option: Option, index: number, itemCount: naria-posinset={index + 1}aria-setsize={itemCount}disabled={option.disabled}- className="h-auto min-h-8 py-1.5">- <ComboboxItemText className="flex items-center gap-2 px-0">+ <ComboboxItemText className="flex items-center gap-2">{option.icon && (<span aria-hidden className={cn(option.icon, 'size-4 shrink-0 text-text-tertiary')} />)}@@ -451,11 +445,7 @@ function VirtualizedModelList({function FilteredModelStatus() {const filteredItems = useComboboxFilteredItems<Option>()- return (- <ComboboxStatus className="border-y border-divider-subtle px-2 py-1 text-text-quaternary tabular-nums">- {filteredItems.length} matching models- </ComboboxStatus>- )+ return <ComboboxStatus>{filteredItems.length} matching models</ComboboxStatus>}function VirtualizedLongListDemo() {@@ -570,22 +560,19 @@ function AsyncDirectoryDemo() {})}}>- <ComboboxInputGroup className="h-8 min-h-8 px-2">+ <ComboboxInputGroup><spanaria-hidden- className="mr-0.5 i-ri-search-line size-4 shrink-0 text-components-input-text-placeholder"- />- <ComboboxInput- placeholder="Search owners…"- className="block h-4.5 grow px-1 py-0 system-sm-regular text-components-input-text-filled"+ className="i-ri-search-line size-4 shrink-0 text-components-input-text-placeholder"/>- <ComboboxClear className="mr-0.5" />- <ComboboxInputTrigger className="mr-0" />+ <ComboboxInput placeholder="Search owners…" />+ <ComboboxClear />+ <ComboboxInputTrigger /></ComboboxInputGroup><ComboboxPortal><ComboboxPositioner>- <ComboboxPopup className="w-105" aria-busy={isPending || undefined}>- <ComboboxStatus className="border-b border-divider-subtle">{status}</ComboboxStatus>+ <ComboboxPopup aria-busy={isPending || undefined}>+ <ComboboxStatus>{status}</ComboboxStatus><ComboboxList<Option>>{renderOptionItem}</ComboboxList><ComboboxEmpty>{emptyMessage}</ComboboxEmpty></ComboboxPopup>@@ -625,16 +612,12 @@ function InlinePopoverDemo() {onInputValueChange={setInputValue}><div className="p-2 pb-1">- <ComboboxInputGroup className="h-8 min-h-8 px-2">+ <ComboboxInputGroup><spanaria-hidden- className="mr-0.5 i-ri-search-line size-4 shrink-0 text-components-input-text-placeholder"- />- <ComboboxInput- aria-label="Search reviewers"- placeholder="Search reviewers…"- className="block h-4.5 grow px-1 py-0 system-sm-regular text-components-input-text-filled"+ className="i-ri-search-line size-4 shrink-0 text-components-input-text-placeholder"/>+ <ComboboxInput aria-label="Search reviewers" placeholder="Search reviewers…" /></ComboboxInputGroup></div><ComboboxList<Option>>{renderOptionItem}</ComboboxList>@@ -672,17 +655,14 @@ export const Default: Story = {<Field name="dataSource" className={fieldWidth}><FieldLabel>Connect source</FieldLabel><Combobox items={dataSourceOptions} defaultValue={defaultDataSource}>- <ComboboxInputGroup className="h-8 min-h-8 px-2">+ <ComboboxInputGroup><spanaria-hidden- className="mr-0.5 i-ri-search-line size-4 shrink-0 text-components-input-text-placeholder"+ className="i-ri-search-line size-4 shrink-0 text-components-input-text-placeholder"/>- <ComboboxInput- placeholder="Search data sources…"- className="block h-4.5 grow px-1 py-0 system-sm-regular text-components-input-text-filled"- />- <ComboboxClear className="mr-0.5" />- <ComboboxInputTrigger className="mr-0" />+ <ComboboxInput placeholder="Search data sources…" />+ <ComboboxClear />+ <ComboboxInputTrigger /></ComboboxInputGroup><ComboboxPortal><ComboboxPositioner>@@ -716,7 +696,7 @@ export const TriggerWithPopupInput: Story = {<div className={fieldWidth}><Combobox items={dataSourceOptions} defaultValue={defaultPopupDataSource}><ComboboxLabel>Data source</ComboboxLabel>- <ComboboxTrigger className="group/trigger flex h-8 w-full min-w-0 items-center gap-0.5 rounded-lg bg-components-input-bg-normal px-3 py-2 text-start system-sm-regular text-components-input-text-filled transition-colors hover:bg-state-base-hover-alt focus-visible:bg-state-base-hover-alt data-placeholder:text-components-input-text-placeholder data-popup-open:bg-state-base-hover-alt motion-reduce:transition-none">+ <ComboboxTrigger className="group/trigger flex h-8 w-full min-w-0 items-center gap-0.5 rounded-lg bg-components-input-bg-normal py-2 pr-2 pl-3 text-start system-sm-regular text-components-input-text-filled transition-colors hover:bg-state-base-hover-alt focus-visible:bg-state-base-hover-alt data-placeholder:text-components-input-text-placeholder data-popup-open:bg-state-base-hover-alt motion-reduce:transition-none"><span className="min-w-0 grow truncate"><ComboboxValue placeholder="Choose source" /></span>@@ -788,14 +768,14 @@ export const Sizes: Story = {<Field key={size} name={`provider-${size}`}><FieldLabel>{`${size[0]!.toUpperCase()}${size.slice(1)}`}</FieldLabel><Combobox items={sizeOptions} defaultValue={defaultProvider}>- <ComboboxInputGroup size={size} className="px-2">+ <ComboboxInputGroup size={size}><spanaria-hidden- className="mr-0.5 i-ri-search-line size-4 shrink-0 text-components-input-text-placeholder"+ className="i-ri-search-line size-4 shrink-0 text-components-input-text-placeholder"/>- <ComboboxInput size={size} placeholder="Search providers…" className="px-1" />- <ComboboxClear size={size} className="mr-0.5" />- <ComboboxInputTrigger size={size} className="mr-0" />+ <ComboboxInput size={size} placeholder="Search providers…" />+ <ComboboxClear size={size} />+ <ComboboxInputTrigger size={size} /></ComboboxInputGroup><ComboboxPortal><ComboboxPositioner>@@ -839,7 +819,7 @@ function MultipleChipsDemo() {<Field name="reviewers" className={fieldWidth}><FieldLabel>Reviewers</FieldLabel><Combobox items={reviewerOptions} multiple value={value} onValueChange={setValue}>- <ComboboxInputGroup className="h-auto min-h-8 items-start py-1">+ <ComboboxInputGroup className="items-start py-1"><ComboboxValue<Option, true>>{(selectedValue) => {const selectedReviewers = selectedValue ?? []@@ -859,7 +839,7 @@ function MultipleChipsDemo() {))}<ComboboxInputplaceholder={selectedReviewers.length > 0 ? '' : 'Assign reviewers…'}- className="min-w-24 px-1 py-0.5"+ className="min-w-24 py-0.5"/></ComboboxChips>)@@ -922,16 +902,13 @@ export const Empty: Story = {<Field name="connector" className={fieldWidth}><FieldLabel>Connector</FieldLabel><Combobox items={emptyOptions} defaultInputValue="salesforce">- <ComboboxInputGroup className="h-8 min-h-8 px-2">+ <ComboboxInputGroup><spanaria-hidden- className="mr-0.5 i-ri-search-line size-4 shrink-0 text-components-input-text-placeholder"- />- <ComboboxInput- placeholder="Search connectors…"- className="block h-4.5 grow px-1 py-0 system-sm-regular text-components-input-text-filled"+ className="i-ri-search-line size-4 shrink-0 text-components-input-text-placeholder"/>- <ComboboxInputTrigger className="mr-0" />+ <ComboboxInput placeholder="Search connectors…" />+ <ComboboxInputTrigger /></ComboboxInputGroup><ComboboxPortal><ComboboxPositioner>@@ -972,12 +949,9 @@ export const ReadOnly: Story = {<Field name="readOnlySource" className={fieldWidth}><FieldLabel>Read-only source</FieldLabel><Combobox items={dataSourceOptions} defaultValue={readOnlyDataSource} readOnly>- <ComboboxInputGroup className="h-8 min-h-8 px-2">- <ComboboxInput- placeholder="Read-only data source…"- className="block h-4.5 grow px-1 py-0 system-sm-regular text-components-input-text-filled"- />- <ComboboxInputTrigger className="mr-0" />+ <ComboboxInputGroup>+ <ComboboxInput placeholder="Read-only data source…" />+ <ComboboxInputTrigger /></ComboboxInputGroup><ComboboxPortal><ComboboxPositioner>diff --git a/packages/dify-ui/src/combobox/index.tsx b/packages/dify-ui/src/combobox/index.tsxindex b151223a27e..1aa597825b6 100644--- a/packages/dify-ui/src/combobox/index.tsx+++ b/packages/dify-ui/src/combobox/index.tsx@@ -108,24 +108,24 @@ function ComboboxTrigger({ className, type = 'button', ...props }: ComboboxTrigg)}+// The group owns the horizontal padding and the gap, so an icon, the input, and the controls sit in+// it without margins of their own, like `DropdownMenuInputGroup`. The input keeps a narrow inset so+// its text lands where a standalone `Input` of the same size puts it.const comboboxInputGroupVariants = cva([textControlGroupClassName,- 'group/combobox items-center',- // Inside the popup the group is the search box, laid out like `DropdownMenuInputGroup`: it- // lines up with the options on 4px gutters,- // hosts an inline icon, and takes over the horizontal padding from its input and controls.+ 'group/combobox items-center gap-0.5',+ // Inside the popup the group is the search box and lines up with the options on 4px gutters.// 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',+ 'in-data-dify-combobox-popup:mx-1 in-data-dify-combobox-popup:mt-1 in-data-dify-combobox-popup:w-auto',],{variants: {size: {- small: 'min-h-6 rounded-md',- medium: 'min-h-8 rounded-lg',- large: 'min-h-9 rounded-[10px]',+ small: 'min-h-6 rounded-md px-1',+ medium: 'min-h-8 rounded-lg px-2',+ large: 'min-h-9 rounded-[10px] px-3',},},defaultVariants: {@@ -150,17 +150,18 @@ function ComboboxInputGroup({ className, size = 'medium', ...props }: ComboboxInconst comboboxInputVariants = cva([- 'w-0 min-w-0 flex-1 appearance-none border-0 bg-transparent text-components-input-text-filled caret-primary-600 outline-hidden',+ 'w-0 min-w-0 flex-1 appearance-none border-0 bg-transparent px-1 text-components-input-text-filled caret-primary-600 outline-hidden','placeholder:text-components-input-text-placeholder','disabled:cursor-not-allowed disabled:text-components-input-text-filled-disabled disabled:placeholder:text-components-input-text-disabled','enabled:data-readonly:cursor-default',],{variants: {+ // Vertical padding fills the group's min height exactly, so the group never grows past it.size: {- small: 'px-2 py-1 system-xs-regular',- medium: 'px-3 py-1.75 system-sm-regular',- large: 'px-4 py-2 system-md-regular',+ small: 'py-0.75 system-xs-regular',+ medium: 'py-1.75 system-sm-regular',+ large: 'py-1.75 system-md-regular',},},defaultVariants: {@@ -200,9 +201,9 @@ const comboboxControlVariants = cva({variants: {size: {- small: 'me-1 size-4',- medium: 'me-1.5 size-5',- large: 'me-2 size-5',+ small: 'size-4',+ medium: 'size-5',+ large: 'size-5',},},defaultVariants: {@@ -353,9 +354,7 @@ function ComboboxItem<Value = unknown>({ className, ...props }: ComboboxItemProptype ComboboxItemTextProps = React.ComponentProps<'span'>function ComboboxItemText({ className, ...props }: ComboboxItemTextProps) {- return (- <span className={cn('min-w-0 grow truncate px-1 system-sm-medium', className)} {...props} />- )+ return <span className={cn('min-w-0 grow truncate system-sm-medium', className)} {...props} />}function ComboboxItemIndicator({ className, children, ...props }: ComboboxItemIndicatorProps) {@@ -386,10 +385,14 @@ function ComboboxLabel({ className, ...props }: ComboboxLabelProps) {type ComboboxGroupLabelProps = BaseCombobox.GroupLabel.Props+// The list's own padding supplies the rest of the inset, so the label text lines up with the+// item text.function ComboboxGroupLabel({ className, ...props }: ComboboxGroupLabelProps) {return (<BaseCombobox.GroupLabel- className={(state) => cn(floatingGroupLabelClassName, resolveClassName(className, state))}+ className={(state) =>+ cn(floatingGroupLabelClassName, 'px-2', resolveClassName(className, state))+ }{...props}/>)@@ -445,10 +448,7 @@ function ComboboxChips({ className, ...props }: ComboboxChipsProps) {return (<BaseCombobox.ChipsclassName={(state) =>- cn(- 'flex w-full min-w-0 flex-wrap items-center gap-1 px-1',- resolveClassName(className, state),- )+ cn('flex w-full min-w-0 flex-wrap items-center gap-1', resolveClassName(className, state))}{...props}/>diff --git a/packages/dify-ui/src/context-menu/index.tsx b/packages/dify-ui/src/context-menu/index.tsxindex cd29f014192..a5d119625ad 100644--- a/packages/dify-ui/src/context-menu/index.tsx+++ b/packages/dify-ui/src/context-menu/index.tsx@@ -259,7 +259,9 @@ type ContextMenuGroupLabelProps = BaseContextMenu.GroupLabel.Propsfunction ContextMenuGroupLabel({ className, ...props }: ContextMenuGroupLabelProps) {return (<BaseContextMenu.GroupLabel- className={(state) => cn(floatingGroupLabelClassName, resolveClassName(className, state))}+ className={(state) =>+ cn(floatingGroupLabelClassName, 'px-3', resolveClassName(className, state))+ }{...props}/>)diff --git a/packages/dify-ui/src/dropdown-menu/index.tsx b/packages/dify-ui/src/dropdown-menu/index.tsxindex 9438c24ea42..bc7d62a8b03 100644--- a/packages/dify-ui/src/dropdown-menu/index.tsx+++ b/packages/dify-ui/src/dropdown-menu/index.tsx@@ -225,7 +225,9 @@ type DropdownMenuGroupLabelProps = Menu.GroupLabel.Propsfunction DropdownMenuGroupLabel({ className, ...props }: DropdownMenuGroupLabelProps) {return (<Menu.GroupLabel- className={(state) => cn(floatingGroupLabelClassName, resolveClassName(className, state))}+ className={(state) =>+ cn(floatingGroupLabelClassName, 'px-3', resolveClassName(className, state))+ }{...props}/>)diff --git a/packages/dify-ui/src/overlay-shared.ts b/packages/dify-ui/src/overlay-shared.tsindex ef6ebc169c7..b06f99f498e 100644--- a/packages/dify-ui/src/overlay-shared.ts+++ b/packages/dify-ui/src/overlay-shared.ts@@ -9,8 +9,10 @@ export const menuItemClassName =export const menuItemDestructiveClassName ='data-[variant=destructive]:text-text-destructive data-[variant=destructive]:data-highlighted:bg-state-destructive-hover'export const floatingItemIndicatorClassName = 'ms-auto flex shrink-0 items-center text-text-accent'+// The horizontal inset belongs to the component: it depends on whether the label sits in the+// popup (12px) or in a padded list (8px, with the list's padding supplying the rest).export const floatingGroupLabelClassName =- 'px-3 pb-0.5 pt-1 text-text-tertiary system-xs-medium-uppercase'+ 'pb-0.5 pt-1 text-text-tertiary system-xs-medium-uppercase'export const floatingSeparatorClassName = 'my-1 h-px bg-divider-subtle'export const menuPopupBaseClassName ='max-h-(--available-height) overflow-y-auto overflow-x-hidden text-sm text-text-secondary outline-hidden focus:outline-hidden focus-visible:outline-hidden'diff --git a/packages/dify-ui/src/select/index.tsx b/packages/dify-ui/src/select/index.tsxindex 6dbcf2146c7..998bda89b22 100644--- a/packages/dify-ui/src/select/index.tsx+++ b/packages/dify-ui/src/select/index.tsx@@ -79,9 +79,11 @@ const selectTriggerVariants = cva({variants: {size: {- small: 'h-6 gap-px rounded-md px-2 py-1 system-xs-regular',- medium: 'h-8 gap-0.5 rounded-lg px-3 py-2 system-sm-regular',- large: 'h-9 gap-0.5 rounded-[10px] px-4 py-2 system-md-regular',+ // The text sits 4px further in than the icon: 8px around the control, 4px more for text.+ // Physical padding, so callers' `px-*`/`pl-*`/`pr-*` overrides keep replacing it.+ small: 'h-6 gap-px rounded-md py-1 pr-1 pl-2 system-xs-regular',+ medium: 'h-8 gap-0.5 rounded-lg py-2 pr-2 pl-3 system-sm-regular',+ large: 'h-9 gap-0.5 rounded-[10px] py-2 pr-3 pl-4 system-md-regular',},},defaultVariants: {@@ -124,10 +126,14 @@ function SelectLabel({ className, ...props }: SelectLabelProps) {type SelectGroupLabelProps = BaseSelect.GroupLabel.Props+// The list's own padding supplies the rest of the inset, so the label text lines up with the+// item text.function SelectGroupLabel({ className, ...props }: SelectGroupLabelProps) {return (<BaseSelect.GroupLabel- className={(state) => cn(floatingGroupLabelClassName, resolveClassName(className, state))}+ className={(state) =>+ cn(floatingGroupLabelClassName, 'px-2', resolveClassName(className, state))+ }{...props}/>)@@ -252,9 +258,7 @@ type SelectItemTextProps = BaseSelect.ItemText.Propsfunction SelectItemText({ className, ...props }: SelectItemTextProps) {return (<BaseSelect.ItemText- className={(state) =>- cn('me-1 min-w-0 grow truncate px-1', resolveClassName(className, state))- }+ className={(state) => cn('me-1 min-w-0 grow truncate', resolveClassName(className, state))}{...props}/>)diff --git a/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/overview/time-range-picker/range-selector.tsx b/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/overview/time-range-picker/range-selector.tsxindex 6805ea62252..e1be177fe04 100644--- a/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/overview/time-range-picker/range-selector.tsx+++ b/web/app/(commonLayout)/app/(appDetailLayout)/[appId]/overview/time-range-picker/range-selector.tsx@@ -93,7 +93,7 @@ const RangeSelector: FC<Props> = ({ isCustomRange, ranges, onSelect }) => {value={item.value}className="relative h-8 py-0 pr-2 pl-7 system-md-regular">- <SelectItemText className="px-0">{item.name}</SelectItemText>+ <SelectItemText>{item.name}</SelectItemText><SelectItemIndicator className="absolute top-2 left-2 ml-0" /></SelectItem>))}diff --git a/web/app/components/app/configuration/config-var/config-modal/type-select.tsx b/web/app/components/app/configuration/config-var/config-modal/type-select.tsxindex c1a7b6aa8f9..9012c4eef79 100644--- a/web/app/components/app/configuration/config-var/config-modal/type-select.tsx+++ b/web/app/components/app/configuration/config-var/config-modal/type-select.tsx@@ -103,7 +103,7 @@ const TypeSelector: FC<Props> = ({className="h-9 justify-between px-2 text-text-secondary"title={item.name}>- <SelectItemText className="flex items-center space-x-2 px-0">+ <SelectItemText className="flex items-center space-x-2"><InputVarTypeIcontype={item.value}className="size-4 shrink-0 text-text-secondary"diff --git a/web/app/components/app/deploy/shared/deployment-configuration/credential-field.tsx b/web/app/components/app/deploy/shared/deployment-configuration/credential-field.tsxindex 292b80ef096..b6249caedcf 100644--- a/web/app/components/app/deploy/shared/deployment-configuration/credential-field.tsx+++ b/web/app/components/app/deploy/shared/deployment-configuration/credential-field.tsx@@ -71,7 +71,7 @@ export function CredentialField({if (nextValue) onChange(nextValue)}}>- <SelectTrigger aria-label={name} className="px-2">+ <SelectTrigger aria-label={name} className="pl-2"><span className="flex min-w-0 items-center gap-1.5"><StatusDot /><span className="truncate">@@ -109,7 +109,7 @@ export function CredentialField({<span className="flex size-2 shrink-0 items-center justify-center"><StatusDot size="small" /></span>- <SelectItemText className="me-0 px-0 system-md-regular">+ <SelectItemText className="me-0 system-md-regular">{candidate.display_name || candidate.credential_id}</SelectItemText></SelectItem>diff --git a/web/app/components/apps/__tests__/creators-filter.spec.tsx b/web/app/components/apps/__tests__/creators-filter.spec.tsxindex 98849d51f5f..2b16f309643 100644--- a/web/app/components/apps/__tests__/creators-filter.spec.tsx+++ b/web/app/components/apps/__tests__/creators-filter.spec.tsx@@ -52,7 +52,7 @@ describe('CreatorsFilter', () => {expect(screen.queryByText('Pending User')).not.toBeInTheDocument()})- it('should search creators, clear keywords, and select a creator', async () => {+ it('should search creators, clear the query, and select a creator', async () => {const user = userEvent.setup()render(<CreatorsFilter value={[]} onChange={mockOnChange} />)@@ -69,7 +69,7 @@ describe('CreatorsFilter', () => {expect(searchInput).toHaveAttribute('aria-activedescendant', zoeOption.id)})- await user.click(screen.getByRole('button', { name: 'common.operation.clear' }))+ await user.clear(searchInput)expect(searchInput).toHaveValue('')expect(searchInput).toHaveFocus()@@ -79,23 +79,6 @@ describe('CreatorsFilter', () => {expect(mockOnChange).toHaveBeenCalledWith(['member-3'])})- it('should clear only the search query from the input action', async () => {- const user = userEvent.setup()- render(<CreatorsFilter value={['member-2']} onChange={mockOnChange} />)-- await user.click(screen.getByRole('combobox', { name: 'app.studio.filters.creators' }))- const searchInput = screen.getByRole('combobox', {- name: 'app.studio.filters.searchCreators',- })- await user.type(searchInput, 'zo')- await user.click(screen.getByRole('button', { name: 'common.operation.clear' }))-- expect(searchInput).toHaveValue('')- expect(searchInput).toHaveFocus()- expect(screen.getByRole('option', { name: /Alice/ })).toHaveAttribute('aria-selected', 'true')- expect(mockOnChange).not.toHaveBeenCalled()- })-it('should return focus to the trigger after clearing creators from the filter chip', async () => {const user = userEvent.setup()render(<StatefulCreatorsFilter initialValue={['member-2', 'member-3']} />)diff --git a/web/app/components/apps/creators-filter.tsx b/web/app/components/apps/creators-filter.tsxindex f4da792a6eb..22c2652ce5f 100644--- a/web/app/components/apps/creators-filter.tsx+++ b/web/app/components/apps/creators-filter.tsx@@ -20,7 +20,7 @@ import {} from '@langgenius/dify-ui/combobox'import { IconButton } from '@langgenius/dify-ui/icon-button'import { useSuspenseQuery } from '@tanstack/react-query'-import { useCallback, useMemo, useRef, useState } from 'react'+import { useCallback, useMemo, useRef } from 'react'import { useTranslation } from 'react-i18next'import { userProfileQueryOptions } from '@/features/account-profile/client'import { useMembers } from '@/service/use-common'@@ -47,9 +47,7 @@ const CreatorsFilter = ({ value, onChange }: CreatorsFilterProps) => {select: (data) => data.profile.id,})const { data: membersData } = useMembers()- const [keywords, setKeywords] = useState('')const triggerRef = useRef<HTMLButtonElement>(null)- const searchInputRef = useRef<HTMLInputElement>(null)const creatorOptions = useMemo<CreatorOption[]>(() => {const members = membersData?.accounts ?? []@@ -87,15 +85,8 @@ 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()- }, [])-const handleSelectionClear = useCallback(() => {onChange([])- setKeywords('')triggerRef.current?.focus()}, [onChange])@@ -117,8 +108,6 @@ const CreatorsFilter = ({ value, onChange }: CreatorsFilterProps) => {autoHighlightitems={creatorItems}value={value}- inputValue={keywords}- onInputValueChange={setKeywords}onValueChange={(nextValue) => onChange(nextValue)}><div className="relative inline-flex h-8 items-stretch">@@ -180,22 +169,11 @@ const CreatorsFilter = ({ value, onChange }: CreatorsFilterProps) => {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">diff --git a/web/app/components/base/form/components/base/base-field.tsx b/web/app/components/base/form/components/base/base-field.tsxindex 0a3ce35a610..103829605cd 100644--- a/web/app/components/base/form/components/base/base-field.tsx+++ b/web/app/components/base/form/components/base/base-field.tsx@@ -396,7 +396,7 @@ const BaseField = ({)}{isSelect && (<>- <SelectTrigger id={controlId} {...controlProps} className="px-2">+ <SelectTrigger id={controlId} {...controlProps}>{multiple ? (<SelectValue<string, true> placeholder={selectPlaceholder}>{(selectedValue) =>diff --git a/web/app/components/base/form/components/field/input-type-select/index.tsx b/web/app/components/base/form/components/field/input-type-select/index.tsxindex 08cff7ffcc9..896b5fd33b4 100644--- a/web/app/components/base/form/components/field/input-type-select/index.tsx+++ b/web/app/components/base/form/components/field/input-type-select/index.tsx@@ -42,7 +42,7 @@ const InputTypeSelectField = ({disabled={disabled}onValueChange={handleInputTypeChange}>- <SelectTrigger id={field.name} className="gap-x-0.5 px-2">+ <SelectTrigger id={field.name} className="gap-x-0.5 pl-2"><Trigger option={selected} /></SelectTrigger><SelectContent className="w-92 bg-components-panel-bg-blur shadow-shadow-shadow-5">diff --git a/web/app/components/base/form/components/field/select.tsx b/web/app/components/base/form/components/field/select.tsxindex 01e3fa25721..76acee69a41 100644--- a/web/app/components/base/form/components/field/select.tsx+++ b/web/app/components/base/form/components/field/select.tsx@@ -70,7 +70,7 @@ const SelectField = ({onChange?.(next)}}>- <SelectTrigger id={field.name} className="px-2">+ <SelectTrigger id={field.name}><SelectValue<string> placeholder={placeholderText}>{(nextValue) => getDisplayLabel(nextValue, options, placeholderText)}</SelectValue>diff --git a/web/app/components/base/icon-picker/emoji-picker.tsx b/web/app/components/base/icon-picker/emoji-picker.tsxindex ef18caef144..dd1393ed942 100644--- a/web/app/components/base/icon-picker/emoji-picker.tsx+++ b/web/app/components/base/icon-picker/emoji-picker.tsx@@ -199,14 +199,13 @@ export const EmojiPicker = memo(({ value, onValueChange, className, ref }: Emoji<div className="shrink-0 border-b border-divider-subtle px-3 pb-2"><AutocompleteInputGroup><span- className="ms-2 i-ri-search-line size-4 shrink-0 text-components-input-text-placeholder"+ className="i-ri-search-line size-4 shrink-0 text-components-input-text-placeholder"aria-hidden="true"/><AutocompleteInputref={ref}aria-label={t(($) => $['iconPicker.search'], { ns: 'app' })}placeholder={t(($) => $['iconPicker.search'], { ns: 'app' })}- className="ps-1.5"/><AutocompleteClear aria-label={t(($) => $['iconPicker.clearSearch'], { ns: 'app' })} /></AutocompleteInputGroup>diff --git a/web/app/components/datasets/common/document-picker/document-list.tsx b/web/app/components/datasets/common/document-picker/document-list.tsxindex 184272e7ce7..0dca1538f50 100644--- a/web/app/components/datasets/common/document-picker/document-list.tsx+++ b/web/app/components/datasets/common/document-picker/document-list.tsx@@ -27,10 +27,10 @@ export default function DocumentList({ className }: Props) {<ComboboxItemkey={item.id}value={item}- className="mx-0 flex h-8 grid-cols-none items-center gap-2 rounded-lg px-3 py-0"+ className="flex h-8 grid-cols-none items-center gap-2 rounded-lg px-3 py-0"><FileIcon name={item.name} extension={extension} size="lg" />- <ComboboxItemText className="min-w-0 px-0 system-sm-regular text-text-secondary">+ <ComboboxItemText className="system-sm-regular text-text-secondary">{item.name}</ComboboxItemText></ComboboxItem>diff --git a/web/app/components/datasets/metadata/metadata-dataset/__tests__/dataset-metadata-picker.spec.tsx b/web/app/components/datasets/metadata/metadata-dataset/__tests__/dataset-metadata-picker.spec.tsxindex bc7f94d94a8..b8cc289f1a2 100644--- a/web/app/components/datasets/metadata/metadata-dataset/__tests__/dataset-metadata-picker.spec.tsx+++ b/web/app/components/datasets/metadata/metadata-dataset/__tests__/dataset-metadata-picker.spec.tsx@@ -106,27 +106,6 @@ describe('DatasetMetadataPicker', () => {expect(await screen.findByRole('status')).toHaveTextContent('common.noData')})- it('should clear only the search query and keep focus in the input', async () => {- const user = userEvent.setup()- const onSelectMetadata = vi.fn()- renderDatasetMetadataPicker({ onSelectMetadata })-- await user.click(screen.getByRole('button', { name: 'dataset.metadata.addMetadata' }))- const searchInput = screen.getByRole('combobox', {- name: 'dataset.metadata.selectMetadata.search',- })- await user.type(searchInput, 'two')- const clearButton = screen.getByRole('button', { name: 'common.operation.clear' })- clearButton.focus()- await user.keyboard('{Enter}')-- expect(searchInput).toHaveValue('')- expect(searchInput).toHaveFocus()- expect(onSelectMetadata).not.toHaveBeenCalled()- expect(screen.getByRole('option', { name: /field_one/ })).toBeInTheDocument()- expect(screen.getByRole('option', { name: /field_three/ })).toBeInTheDocument()- })-it('should reset the search query after the picker finishes closing', async () => {const user = userEvent.setup()renderDatasetMetadataPicker()diff --git a/web/app/components/datasets/metadata/metadata-dataset/dataset-metadata-picker.tsx b/web/app/components/datasets/metadata/metadata-dataset/dataset-metadata-picker.tsxindex 2d86515a479..f95662e6585 100644--- a/web/app/components/datasets/metadata/metadata-dataset/dataset-metadata-picker.tsx+++ b/web/app/components/datasets/metadata/metadata-dataset/dataset-metadata-picker.tsx@@ -14,9 +14,8 @@ import {ComboboxList,ComboboxSeparator,} from '@langgenius/dify-ui/combobox'-import { IconButton } from '@langgenius/dify-ui/icon-button'import { Popover, PopoverContent, PopoverTitle, PopoverTrigger } from '@langgenius/dify-ui/popover'-import { useRef, useState } from 'react'+import { useState } from 'react'import { useTranslation } from 'react-i18next'import { useDatasetMetaData } from '@/service/knowledge/use-metadata'import { getIconClassName } from '../utils/get-icon'@@ -63,11 +62,9 @@ export function DatasetMetadataPicker({const metadataItems = datasetMetaData?.doc_metadata ?? []const [open, setOpen] = useState(false)const [view, setView] = useState<PickerView>(PickerView.select)- const [query, setQuery] = useState('')const resetPickerState = () => {setView(PickerView.select)- setQuery('')}const handleOpenChangeComplete = (nextOpen: boolean) => {@@ -76,7 +73,6 @@ export function DatasetMetadataPicker({const handleStartMetadataCreation = () => {setView(PickerView.create)- setQuery('')}const handleSelectMetadata = (metadata: MetadataItem | null) => {@@ -136,15 +132,11 @@ export function DatasetMetadataPicker({onOpenChange={setOpen}value={null}items={metadataItems}- inputValue={query}- onInputValueChange={setQuery}onValueChange={handleSelectMetadata}itemToStringLabel={getMetadataLabel}filter={metadataFilter}><MetadataPickerSelectPanel- query={query}- onClearQuery={() => setQuery('')}onStartMetadataCreation={handleStartMetadataCreation}onOpenMetadataManagement={handleOpenMetadataManagement}/>@@ -163,49 +155,26 @@ export function DatasetMetadataPicker({}function MetadataPickerSelectPanel({- query,- onClearQuery,onStartMetadataCreation,onOpenMetadataManagement,}: {- query: string- onClearQuery: () => voidonStartMetadataCreation: () => voidonOpenMetadataManagement: () => void}) {const { t } = useTranslation(['common', 'dataset'])- const inputRef = useRef<HTMLInputElement>(null)-- const handleClearQuery = () => {- onClearQuery()- inputRef.current?.focus()- }return (<><div className="p-2 pb-1"><ComboboxInputGroup><span- className="ml-2 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- ref={inputRef}aria-label={t(($) => $[`${i18nPrefix}.search`], { ns: 'dataset' })}placeholder={t(($) => $[`${i18nPrefix}.search`], { ns: 'dataset' })}- className="pl-2"/>- {query && (- <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={handleClearQuery}- onMouseDown={(event) => event.preventDefault()}- >- <span className="i-ri-close-line size-4" aria-hidden="true" />- </IconButton>- )}</ComboboxInputGroup></div><ComboboxList<MetadataItem>>@@ -226,7 +195,7 @@ function MetadataOption({ metadata }: { metadata: MetadataItem }) {return (<ComboboxItem value={metadata}>- <ComboboxItemText className="flex items-center gap-1.5 px-0">+ <ComboboxItemText className="flex items-center gap-1.5"><span className={cn(iconClassName, 'size-3.5 shrink-0')} aria-hidden="true" /><span className="min-w-0 grow truncate">{metadata.name}</span></ComboboxItemText>diff --git a/web/app/components/plugins/marketplace/home/__tests__/embedded-marketplace-search.spec.tsx b/web/app/components/plugins/marketplace/home/__tests__/embedded-marketplace-search.spec.tsxindex dffc78ceb6a..f13b6364b7e 100644--- a/web/app/components/plugins/marketplace/home/__tests__/embedded-marketplace-search.spec.tsx+++ b/web/app/components/plugins/marketplace/home/__tests__/embedded-marketplace-search.spec.tsx@@ -1,5 +1,5 @@import { QueryClient, QueryClientProvider } from '@tanstack/react-query'-import { screen, waitFor, within } from '@testing-library/react'+import { fireEvent, screen, waitFor, within } from '@testing-library/react'import userEvent from '@testing-library/user-event'import { afterEach, beforeEach, describe, expect, it, vi } from 'vite-plus/test'import { renderWithNuqs } from '@/test/nuqs-testing'@@ -25,13 +25,12 @@ const { debounceState, mockPluginSearch, mockTemplateSearch, mockCheckInstalled}),)-vi.mock('ahooks', async (importOriginal) => {- const original = await importOriginal<typeof import('ahooks')>()+vi.mock('foxact/use-debounced-value', async (importOriginal) => {+ const original = await importOriginal<typeof import('foxact/use-debounced-value')>()return {- ...original,- useDebounce: <T,>(value: T, options?: { wait?: number }) =>- debounceState.useRealDebounce ? original.useDebounce(value, options) : value,+ useDebouncedValue: (value: string, wait: number) =>+ debounceState.useRealDebounce ? original.useDebouncedValue(value, wait) : value,}})@@ -247,8 +246,11 @@ describe('EmbeddedMarketplaceSearch', () => {const { onUrlUpdate } = renderSearch()await user.type(screen.getByRole('combobox'), 'google')- await user.hover(await screen.findByRole('option', { name: /Google Search/ }))- await user.keyboard('{Enter}')+ await screen.findByRole('option', { name: /Google Search/ })+ // Nothing is highlighted, so Enter is left to the browser's implicit form submission;+ // happy-dom has none, so the form is submitted here.+ expect(fireEvent.keyDown(screen.getByRole('combobox'), { key: 'Enter' })).toBe(true)+ fireEvent.submit(screen.getByRole('combobox').closest('form')!)await waitFor(() => {expect(onUrlUpdate.mock.calls.at(-1)?.[0].searchParams.get('q')).toBe('google')diff --git a/web/app/components/plugins/marketplace/home/__tests__/marketplace-search-autocomplete.browser.spec.tsx b/web/app/components/plugins/marketplace/home/__tests__/marketplace-search-autocomplete.browser.spec.tsxindex 6b27a9ca91d..9e367eef809 100644--- a/web/app/components/plugins/marketplace/home/__tests__/marketplace-search-autocomplete.browser.spec.tsx+++ b/web/app/components/plugins/marketplace/home/__tests__/marketplace-search-autocomplete.browser.spec.tsx@@ -2,27 +2,25 @@ import type { ReactNode } from 'react'import { QueryClient, QueryClientProvider } from '@tanstack/react-query'import { useAtomValue } from 'jotai'import { useState } from 'react'-import { page } from 'vite-plus/test/browser'+import { page, userEvent } from 'vite-plus/test/browser'import { render } from 'vitest-browser-react'import { MARKETPLACE_CONTAINER_ID } from '../../constants'import HomeCatalogNavigation from '../home-catalog-navigation'import HomeSearch from '../home-search'import { homeCatalogPinnedAtom } from '../home-sticky-state'import { HomeStickyStateProvider } from '../home-sticky-state-provider'-import { MarketplaceSearchAutocomplete } from '../marketplace-search-autocomplete'+import {+ MarketplaceSearchAutocomplete,+ MarketplaceSearchForm,+} from '../marketplace-search-autocomplete'const { mockTemplateSearch } = vi.hoisted(() => ({mockTemplateSearch: vi.fn(),}))-vi.mock('ahooks', async (importOriginal) => {- const original = await importOriginal<typeof import('ahooks')>()-- return {- ...original,- useDebounce: <T,>(value: T) => value,- }-})+vi.mock('foxact/use-debounced-value', () => ({+ useDebouncedValue: <T,>(value: T) => value,+}))vi.mock('react-i18next', async (importOriginal) => {const original = await importOriginal<typeof import('react-i18next')>()@@ -160,8 +158,43 @@ describe('Marketplace search autocomplete layout', () => {await expect.element(screen.getByText('No templates found')).toBeVisible()expect(scrollContainer.scrollTop).toBe(scrollTopBefore)- await expect.element(screen.getByRole('tablist', { name: 'Header catalog tabs' })).toBeVisible()+ // Base UI hides the page outside the open suggestions from assistive technology, so the+ // pinned tabs are only reachable when hidden elements are included.+ await expect+ .element(screen.getByRole('tablist', { name: 'Header catalog tabs', includeHidden: true }))+ .toBeVisible()expect(input.element().getBoundingClientRect().top).toBeCloseTo(inputTopBefore)expect(catalogNavigation.getBoundingClientRect().top).toBeCloseTo(navigationTopBefore)})++ // The search owns no Enter handler: the browser's implicit submission submits the route form+ // when no suggestion is highlighted. Only a real browser performs that submission.+ it('submits the route search form on Enter when no suggestion is highlighted', async () => {+ const handleSubmit = vi.fn((event: Event) => {+ event.preventDefault()+ })++ const screen = await render(+ <Wrapper>+ <MarketplaceSearchForm+ action="/search/templates"+ locale="en-US"+ placeholder="Search templates"+ query=""+ scope="templates"+ />+ </Wrapper>,+ )++ screen.container.querySelector('form')!.addEventListener('submit', handleSubmit)++ const input = screen.getByRole('combobox', { name: 'Search templates' })+ await input.fill('open')+ await expect.element(screen.getByText('No templates found')).toBeVisible()++ await userEvent.keyboard('{Enter}')++ expect(handleSubmit).toHaveBeenCalledOnce()+ await expect.element(input).toHaveValue('open')+ })})diff --git a/web/app/components/plugins/marketplace/home/__tests__/marketplace-search-autocomplete.spec.tsx b/web/app/components/plugins/marketplace/home/__tests__/marketplace-search-autocomplete.spec.tsxindex 64fa3078f7d..c7161d39345 100644--- a/web/app/components/plugins/marketplace/home/__tests__/marketplace-search-autocomplete.spec.tsx+++ b/web/app/components/plugins/marketplace/home/__tests__/marketplace-search-autocomplete.spec.tsx@@ -19,13 +19,12 @@ const { debounceState, mockAssign, mockPluginSearch, mockTemplateSearch } = vi.hmockTemplateSearch: vi.fn(),}))-vi.mock('ahooks', async (importOriginal) => {- const original = await importOriginal<typeof import('ahooks')>()+vi.mock('foxact/use-debounced-value', async (importOriginal) => {+ const original = await importOriginal<typeof import('foxact/use-debounced-value')>()return {- ...original,- useDebounce: <T,>(value: T, options?: { wait?: number }) =>- debounceState.useRealDebounce ? original.useDebounce(value, options) : value,+ useDebouncedValue: (value: string, wait: number) =>+ debounceState.useRealDebounce ? original.useDebouncedValue(value, wait) : value,}})@@ -265,7 +264,7 @@ describe('MarketplaceSearchAutocomplete', () => {expect(handleSubmit).not.toHaveBeenCalled()})- it('submits the typed query on Enter without selecting a hovered suggestion', async () => {+ it('leaves Enter to the form submission when no suggestion is highlighted', async () => {mockTemplateSearch.mockResolvedValue({data: {templates: [@@ -318,13 +317,25 @@ describe('MarketplaceSearchAutocomplete', () => {container.querySelector('form')?.addEventListener('submit', handleSubmit)await user.type(screen.getByRole('combobox'), 'search')- await user.hover(await screen.findByRole('option', { name: /Legal Research Agent/ }))- fireEvent.keyDown(screen.getByRole('combobox'), { key: 'Enter', isComposing: true })+ await screen.findByRole('option', { name: /Legal Research Agent/ })++ // An IME confirmation keeps the suggestions open and submits nothing.+ fireEvent.keyDown(screen.getByRole('combobox'), {+ key: 'Enter',+ keyCode: 229,+ which: 229,+ isComposing: true,+ })expect(handleSubmit).not.toHaveBeenCalled()- await user.keyboard('{Enter}')+ expect(screen.getByRole('option', { name: /Legal Research Agent/ })).toBeInTheDocument()- expect(handleSubmit).toHaveBeenCalledOnce()+ // Nothing is highlighted, so Enter is not consumed and the browser's implicit form submission+ // runs; happy-dom has none, so the browser spec covers the submit.+ expect(fireEvent.keyDown(screen.getByRole('combobox'), { key: 'Enter' })).toBe(true)expect(screen.getByRole('combobox')).toHaveValue('search')+ await waitFor(() => {+ expect(screen.queryByRole('listbox')).not.toBeInTheDocument()+ })})it('opens plugin detail when a suggestion is chosen', async () => {@@ -523,7 +534,7 @@ describe('MarketplaceSearchAutocomplete', () => {expect(screen.getByRole('combobox')).toHaveValue('')})- it('does not offer the previous term suggestions while a new search is pending', async () => {+ it('keeps the previous suggestions listed under a loading status while a new search is pending', async () => {const googleResponse = {data: {plugins: [@@ -541,8 +552,7 @@ describe('MarketplaceSearchAutocomplete', () => {}mockPluginSearch.mockImplementation((input: { body: { query: string } }) => {if (input.body.query === 'google') return Promise.resolve(googleResponse)- // Keep the follow-up term pending so stale suggestions would be visible- // if the query still returned placeholder data.+ // Keep the follow-up term pending so the loading state stays observable.return new Promise(() => {})})const user = userEvent.setup()@@ -568,7 +578,7 @@ describe('MarketplaceSearchAutocomplete', () => {await user.type(screen.getByRole('combobox'), ' drive')- expect(screen.queryByText('Google Search')).not.toBeInTheDocument()+ expect(screen.getByText('Google Search')).toBeInTheDocument()expect(screen.getByText(/Loading/)).toBeInTheDocument()expect(screen.getByText(/Loading/).closest('[aria-busy="true"]')).not.toBeNull()})@@ -619,9 +629,12 @@ describe('MarketplaceSearchAutocomplete', () => {await user.type(screen.getByRole('combobox'), 'google')expect(screen.getByText(/Loading/)).toBeInTheDocument()- await user.click(screen.getByRole('button', { name: 'Outside search' }))+ // Base UI hides the rest of the page from assistive technology while the suggestions are+ // open, so the outside control is reached by text rather than by role.+ await user.click(screen.getByText('Outside search'))await waitFor(() => {- expect(screen.getByText(/Loading/)).not.toBeVisible()+ const loading = screen.queryByText(/Loading/)+ if (loading) expect(loading).not.toBeVisible()})resolvePluginSearch(pluginResponse)@@ -660,7 +673,7 @@ describe('MarketplaceSearchAutocomplete', () => {expect(screen.queryByText(/Loading/)).not.toBeInTheDocument()})- it('clears suggestions while the edited value is still debouncing', async () => {+ it('keeps the previous suggestions listed while the edited value is still debouncing', async () => {debounceState.useRealDebounce = truemockPluginSearch.mockResolvedValue({data: {@@ -700,10 +713,10 @@ describe('MarketplaceSearchAutocomplete', () => {expect(await screen.findByText('Google Search')).toBeInTheDocument()// For the first 300ms after editing, the debounced term still points at- // the old query; the previous suggestions must already be gone.+ // the old query; its suggestions stay listed under the loading status.await user.type(screen.getByRole('combobox'), ' drive')- expect(screen.queryByText('Google Search')).not.toBeInTheDocument()+ expect(screen.getByText('Google Search')).toBeInTheDocument()expect(screen.getByText(/Loading/)).toBeInTheDocument()expect(screen.getByText(/Loading/).closest('[aria-busy="true"]')).not.toBeNull()})diff --git a/web/app/components/plugins/marketplace/home/marketplace-search-autocomplete.tsx b/web/app/components/plugins/marketplace/home/marketplace-search-autocomplete.tsxindex 5d3be387357..71b3d8db5c1 100644--- a/web/app/components/plugins/marketplace/home/marketplace-search-autocomplete.tsx+++ b/web/app/components/plugins/marketplace/home/marketplace-search-autocomplete.tsx@@ -13,6 +13,7 @@ import {AutocompleteItem,AutocompleteItemText,AutocompleteList,+ AutocompletePopup,AutocompletePortal,AutocompletePositioner,AutocompleteSeparator,@@ -20,9 +21,10 @@ import {useAutocompleteFilteredItems,} from '@langgenius/dify-ui/autocomplete'import { cn } from '@langgenius/dify-ui/cn'-import { useQuery } from '@tanstack/react-query'-import { useDebounce } from 'ahooks'-import { useEffect, useRef, useState } from 'react'+import { SpinnerIcon } from '@langgenius/dify-ui/spinner'+import { keepPreviousData, useQuery } from '@tanstack/react-query'+import { useDebouncedValue } from 'foxact/use-debounced-value'+import { useState } from 'react'import { useTranslation } from '#i18n'import { MARKETPLACE_API_PREFIX } from '@/config'import { renderI18nObject } from '@/i18n/metadata'@@ -98,17 +100,26 @@ const toPluginSuggestion = (plugin: MarketplacePlugin, locale: string): Marketpl})function MarketplaceSuggestionList({+ pending,onSelect,}: {+ pending: booleanonSelect: (selection: MarketplaceSearchSelection) => void}) {const groups = useAutocompleteFilteredItems<MarketplaceSuggestionGroup>()return (- <AutocompleteList className="max-h-none overflow-visible p-0 data-empty:p-0">+ // The list is the scroll container. Its scroll padding matches the group label height so+ // keyboard navigation keeps the label above a group's first item in view.+ <AutocompleteList+ className={cn(+ 'scroll-pt-9 transition-opacity motion-reduce:transition-none',+ pending && 'opacity-60',+ )}+ >{groups.map((group, groupIndex) => (- <AutocompleteGroup key={group.id} items={group.items} className="p-1">- {groupIndex > 0 && <AutocompleteSeparator className="-mx-1 mb-1" />}+ <AutocompleteGroup key={group.id} items={group.items}>+ {groupIndex > 0 && <AutocompleteSeparator />}<AutocompleteGroupLabel className="px-3 pt-3 pb-2 system-xs-semibold-uppercase text-text-primary">{group.label}</AutocompleteGroupLabel>@@ -117,7 +128,7 @@ function MarketplaceSuggestionList({<AutocompleteItemkey={item.id}value={item}- className="mx-0 items-start gap-1 rounded-lg py-1 pr-1 pl-3 hover:text-text-primary not-data-highlighted:hover:bg-state-base-hover"+ className="items-start gap-1 py-1 pr-1 pl-3"onClick={() => onSelect(item.selection)}><span className="flex shrink-0 items-start py-1">@@ -148,7 +159,7 @@ function MarketplaceSuggestionList({)}</span><span className="flex min-w-0 flex-1 flex-col gap-0.5 p-1">- <AutocompleteItemText className="px-0 system-md-medium text-text-primary">+ <AutocompleteItemText className="system-md-medium text-text-primary">{item.label}</AutocompleteItemText>{!!item.description && (@@ -184,33 +195,20 @@ export function MarketplaceSearchAutocomplete({const { t } = useTranslation(['app'])const { t: tCommon } = useTranslation(['common'])const { t: tPlugin } = useTranslation(['plugin'])- const [isOpen, setIsOpen] = useState(false)- const searchRootRef = useRef<HTMLDivElement>(null)- const resultsPanelRef = useRef<HTMLDivElement>(null)- const keyboardHighlightedRef = useRef(false)-- const submitSearchForm = () => {- const form = searchRootRef.current?.closest('form')- if (form instanceof HTMLFormElement) form.requestSubmit()- }const openSuggestion = (selection: MarketplaceSearchSelection) => {if (onSuggestionSelect) {const result = onSuggestionSelect(selection)- queueMicrotask(() => {- if (!result?.preserveQuery) onValueChange('')- setIsOpen(false)- })+ if (!result?.preserveQuery) onValueChange('')return}- const href =+ window.location.assign(selection.kind === 'plugin'? getPluginDetailLinkInMarketplace(selection.plugin)- : getTemplateDetailLinkInMarketplace(selection.template)- setIsOpen(false)- window.location.assign(href)+ : getTemplateDetailLinkInMarketplace(selection.template),+ )}- const debouncedSearch = useDebounce(value.trim(), { wait: 300 })+ const debouncedSearch = useDebouncedValue(value.trim(), 300)const hasQuery = Boolean(debouncedSearch)const searchesPlugins = scope === 'all' || scope === 'plugins'const searchesTemplates = scope === 'all' || scope === 'templates'@@ -230,8 +228,10 @@ export function MarketplaceSearchAutocomplete({},retry: false,}),- // No placeholderData here: showing the previous term's suggestions would- // leave stale items keyboard-selectable while the new request is pending.+ // While a query is active, the previous term's suggestions stay listed under a loading+ // status until the next term loads, so the popup does not collapse on every keystroke.+ // Clearing the input drops them.+ placeholderData: hasQuery ? keepPreviousData : undefined,enabled: hasQuery && searchesPlugins,staleTime: 60_000,})@@ -249,23 +249,19 @@ export function MarketplaceSearchAutocomplete({},retry: false,}),+ placeholderData: hasQuery ? keepPreviousData : undefined,enabled: hasQuery && searchesTemplates,staleTime: 60_000,})- // While the edited value is still debouncing, the queries above still hold- // the previous term's data; gate the suggestions until both agree so stale- // options are never visible or keyboard-selectable.const isDebouncing = value.trim() !== debouncedSearch- const pluginSuggestions =- !isDebouncing && searchesPlugins- ? (pluginQuery.data?.data.bundles ?? pluginQuery.data?.data.plugins ?? []).map((plugin) =>- toPluginSuggestion(plugin, locale),- )- : []- const templateSuggestions =- !isDebouncing && searchesTemplates- ? (templateQuery.data?.data?.templates ?? []).map(toTemplateSuggestion)- : []+ const pluginSuggestions = searchesPlugins+ ? (pluginQuery.data?.data.bundles ?? pluginQuery.data?.data.plugins ?? []).map((plugin) =>+ toPluginSuggestion(plugin, locale),+ )+ : []+ const templateSuggestions = searchesTemplates+ ? (templateQuery.data?.data?.templates ?? []).map(toTemplateSuggestion)+ : []const suggestions = [...templateSuggestions, ...pluginSuggestions]const suggestionGroups: MarketplaceSuggestionGroup[] = [...(templateSuggestions.length@@ -287,11 +283,8 @@ export function MarketplaceSearchAutocomplete({]: []),]- const isSearching = isDebouncing || pluginQuery.isFetching || templateQuery.isFetching- // Keep open tied to the typing session so outside-press can dismiss during- // debounce/fetch. Pending, empty, and error copy live inside the popup.- const hasTypedQuery = Boolean(value.trim())- const isPopupOpen = isOpen && hasTypedQuery+ const isFetching = pluginQuery.isFetching || templateQuery.isFetching+ const isSearching = isDebouncing || isFetching// A failed request must not read as "nothing matched"; when every source in// scope errored and nothing is displayable, surface a load failure instead.const hasLoadError =@@ -304,94 +297,80 @@ export function MarketplaceSearchAutocomplete({? t(($) => $['newApp.noTemplateFound'], { ns: 'app' }): tPlugin(($) => $['marketplace.noPluginFound'], { ns: 'plugin' })- useEffect(() => {- if (!isPopupOpen) return-- const handleOutsidePress = (event: MouseEvent) => {- const target = event.target- if (!(target instanceof Node)) return- if (searchRootRef.current?.contains(target) || resultsPanelRef.current?.contains(target))- return- setIsOpen(false)- }-- document.addEventListener('click', handleOutsidePress)- return () => document.removeEventListener('click', handleOutsidePress)- }, [isPopupOpen])-+ // Base UI owns opening on input, outside-press and Escape dismissal, and Enter: it selects the+ // highlighted item or leaves the key to the browser, which submits the form when nothing is+ // highlighted.return (- <div ref={searchRootRef} className="relative">- <Autocomplete- filter={null}- highlightItemOnHover={false}- itemToStringValue={(item) => item.label}- items={suggestionGroups}- mode="list"- name={inputName}- onOpenChange={setIsOpen}- onValueChange={(nextValue) => {- onValueChange(nextValue)- setIsOpen(Boolean(nextValue.trim()))- }}- open={isPopupOpen}- openOnInputClick- submitOnItemClick={false}- value={value}- onItemHighlighted={(item, details) => {- keyboardHighlightedRef.current = Boolean(item) && details.reason === 'keyboard'- }}- >- <AutocompleteInputGroup size="large">- <span- aria-hidden- className="ml-3 i-ri-search-line size-4 shrink-0 text-components-input-text-placeholder"- />- <AutocompleteInput- aria-label={placeholder}- className="px-2 text-sm"- placeholder={placeholder}+ <Autocomplete+ filter={null}+ itemToStringValue={(item) => item.label}+ items={suggestionGroups}+ name={inputName}+ onOpenChange={(nextOpen, details) => {+ // Base UI also opens on arrow keys; with no query there is nothing to show, so that+ // open is cancelled. Typing opens and emptying the input closes.+ if (nextOpen && details.reason !== 'input-change' && !value.trim()) details.cancel()+ }}+ onValueChange={(nextValue, details) => {+ // Choosing a suggestion opens it instead of filling the input, so its label never+ // replaces the typed query.+ if (details.reason !== 'item-press') onValueChange(nextValue)+ }}+ value={value}+ >+ <AutocompleteInputGroup size="large">+ <span+ aria-hidden+ className="i-ri-search-line size-4 shrink-0 text-components-input-text-placeholder"+ />+ <AutocompleteInput+ aria-label={placeholder}+ placeholder={placeholder}+ size="large"+ type="text"+ />+ {!!value && (+ <AutocompleteClear+ aria-label={tPlugin(($) => $.clearSearch, { ns: 'plugin', label: placeholder })}size="large"- type="text"- onKeyDownCapture={(event) => {- if (- event.defaultPrevented ||- event.nativeEvent.isComposing ||- event.key !== 'Enter' ||- !inputName- )- return- if (keyboardHighlightedRef.current) return- event.preventDefault()- event.stopPropagation()- if (value.trim()) submitSearchForm()- }}/>- {!!value && (- <AutocompleteClear- aria-label={tPlugin(($) => $.clearSearch, { ns: 'plugin', label: placeholder })}- size="large"+ )}+ </AutocompleteInputGroup>+ {/* Base UI adds its own text input to the owning form, which blocks the browser's implicit+ submission, so a form field brings the submit button Enter needs. */}+ {inputName && (+ <button type="submit" className="sr-only" tabIndex={-1} aria-hidden>+ {placeholder}+ </button>+ )}+ <AutocompletePortal>+ <AutocompletePositioner sideOffset={8}>+ <AutocompletePopup+ className="max-h-[min(20rem,var(--available-height))] max-w-(--available-width) bg-components-panel-bg-blur shadow-xl backdrop-blur-sm"+ aria-busy={isSearching || undefined}+ >+ {/* The previous suggestions stay listed while the next term loads, dimmed only while a+ request is in flight so a cached result does not flicker; the loading row follows+ them so nothing on screen moves, and it is the content on the first search. */}+ <MarketplaceSuggestionList+ pending={isFetching && suggestions.length > 0}+ onSelect={openSuggestion}/>- )}- </AutocompleteInputGroup>- <AutocompletePortal hidden={!isPopupOpen}>- <AutocompletePositioner anchor={searchRootRef} sideOffset={8}>- <div- ref={resultsPanelRef}- className="max-h-[min(20rem,var(--available-height))] w-(--anchor-width) max-w-(--available-width) overflow-y-auto overscroll-contain rounded-xl border-[0.5px] border-components-panel-border bg-components-panel-bg-blur shadow-xl outline-hidden backdrop-blur-sm"- aria-busy={isSearching || undefined}- >- <MarketplaceSuggestionList onSelect={openSuggestion} />- <AutocompleteEmpty>- {!isSearching && suggestions.length === 0 ? emptyText : null}- </AutocompleteEmpty>- <AutocompleteStatus className="empty:h-0 empty:p-0">- {isSearching ? tCommon(($) => $.loading, { ns: 'common' }) : null}- </AutocompleteStatus>- </div>- </AutocompletePositioner>- </AutocompletePortal>- </Autocomplete>- </div>+ <AutocompleteStatus className="flex items-center gap-2">+ {isSearching ? (+ <>+ <SpinnerIcon />+ {tCommon(($) => $.loading, { ns: 'common' })}+ </>+ ) : null}+ </AutocompleteStatus>+ <AutocompleteEmpty>+ {!isSearching && suggestions.length === 0 ? emptyText : null}+ </AutocompleteEmpty>+ </AutocompletePopup>+ </AutocompletePositioner>+ </AutocompletePortal>+ </Autocomplete>)}diff --git a/web/app/components/plugins/plugin-detail-panel/app-selector/__tests__/app-picker.spec.tsx b/web/app/components/plugins/plugin-detail-panel/app-selector/__tests__/app-picker.spec.tsxindex 360436f187b..8b79cc49196 100644--- a/web/app/components/plugins/plugin-detail-panel/app-selector/__tests__/app-picker.spec.tsx+++ b/web/app/components/plugins/plugin-detail-panel/app-selector/__tests__/app-picker.spec.tsx@@ -84,43 +84,4 @@ describe('AppPicker', () => {expect(scrollRegion).toContainElement(listbox)expect(scrollRegion).toContainElement(loadMoreButton)})-- it('should clear only the search query and keep focus in the input', async () => {- const user = userEvent.setup()- const onSelect = vi.fn()-- function AppPickerHarness() {- const [open, setOpen] = useState(false)- const [searchText, setSearchText] = useState('')-- return (- <AppPicker- disabled={false}- trigger={<span>Choose app</span>}- isShow={open}- onShowChange={setOpen}- onSelect={onSelect}- apps={[app]}- isLoading={false}- hasMore={false}- onLoadMore={vi.fn()}- searchText={searchText}- onSearchChange={setSearchText}- />- )- }-- render(<AppPickerHarness />)- await user.click(screen.getByRole('combobox', { name: 'app.appSelector.label' }))- const searchInput = screen.getByRole('combobox', { name: 'app.appSelector.placeholder' })- await user.type(searchInput, 'workflow')- const clearButton = screen.getByRole('button', { name: 'common.operation.clear' })- clearButton.focus()- await user.keyboard('{Enter}')-- expect(searchInput).toHaveValue('')- expect(searchInput).toHaveFocus()- expect(onSelect).not.toHaveBeenCalled()- expect(screen.getByRole('option', { name: /Workflow App/ })).toBeInTheDocument()- })})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.tsxindex 2593df7a516..eb2d6440b77 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@@ -19,7 +19,6 @@ import {ComboboxStatus,ComboboxTrigger,} from '@langgenius/dify-ui/combobox'-import { IconButton } from '@langgenius/dify-ui/icon-button'import {ScrollArea,ScrollAreaContent,@@ -27,7 +26,7 @@ import {ScrollAreaThumb,ScrollAreaViewport,} from '@langgenius/dify-ui/scroll-area'-import { useCallback, useRef } from 'react'+import { useCallback } from 'react'import { useTranslation } from 'react-i18next'import AppIcon from '@/app/components/base/app-icon'import { AppModeEnum } from '@/types/app'@@ -75,9 +74,9 @@ function AppPickerOption({ app }: { app: AppPartial }) {<ComboboxItemkey={app.id}value={app}- className="mx-0 grid-cols-[minmax(0,1fr)_auto] gap-3 py-1 pr-3 pl-2"+ className="grid-cols-[minmax(0,1fr)_auto] gap-3 py-1 pr-3 pl-2">- <ComboboxItemText className="flex min-w-0 items-center gap-3 px-0">+ <ComboboxItemText className="flex items-center gap-3"><AppIconclassName="shrink-0"size="xs"@@ -114,8 +113,6 @@ export function AppPicker({onSearchChange,}: AppPickerProps) {const { t } = useTranslation(['app', 'common', 'workflow'])- const inputRef = useRef<HTMLInputElement>(null)-const handleValueChange = useCallback((app: AppPartial | null) => {if (!app) return@@ -126,11 +123,6 @@ export function AppPicker({[onSelect, onShowChange],)- const handleClearSearch = () => {- onSearchChange('')- inputRef.current?.focus()- }-return (<Combobox<AppPartial>items={apps}@@ -163,24 +155,9 @@ export function AppPicker({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"><ScrollAreaViewportdiff --git a/web/app/components/workflow/nodes/_base/components/variable/var-type-picker.tsx b/web/app/components/workflow/nodes/_base/components/variable/var-type-picker.tsxindex 6d3d716953e..f052a9b9793 100644--- a/web/app/components/workflow/nodes/_base/components/variable/var-type-picker.tsx+++ b/web/app/components/workflow/nodes/_base/components/variable/var-type-picker.tsx@@ -57,9 +57,9 @@ const VarReferencePicker: FC<Props> = ({ readonly, className, value, onChange })<SelectItem<VarType>key={type}value={type}- className="h-7.5 rounded-lg pr-2 pl-3 text-[13px] text-text-primary"+ className="h-7.5 text-[13px] text-text-primary">- <SelectItemText className="px-0 capitalize">{type}</SelectItemText>+ <SelectItemText className="capitalize">{type}</SelectItemText><SelectItemIndicator /></SelectItem>))}diff --git a/web/app/components/workflow/nodes/if-else/components/condition-list/condition-item.tsx b/web/app/components/workflow/nodes/if-else/components/condition-list/condition-item.tsxindex 55c35799aea..666db4f05f3 100644--- a/web/app/components/workflow/nodes/if-else/components/condition-list/condition-item.tsx+++ b/web/app/components/workflow/nodes/if-else/components/condition-list/condition-item.tsx@@ -369,7 +369,7 @@ const ConditionItem = ({aria-hiddenclassName="mr-1.25 i-custom-vender-solid-development-variable-02 h-3.5 w-3.5 text-text-accent"/>- <SelectItemText className="mr-0 px-0 system-sm-medium text-text-secondary">+ <SelectItemText className="mr-0 system-sm-medium text-text-secondary">{option.name}</SelectItemText></div>@@ -444,7 +444,7 @@ const ConditionItem = ({value={selectedSelectOption?.value ?? null}onValueChange={(value) => value && handleUpdateConditionValue(value)}>- <SelectTrigger className="h-8 rounded-t-none border-0 px-2 text-xs hover:bg-components-input-bg-normal focus-visible:bg-components-input-bg-normal">+ <SelectTrigger className="h-8 rounded-t-none border-0 pl-2 text-xs hover:bg-components-input-bg-normal focus-visible:bg-components-input-bg-normal">{selectedSelectOption?.name ?? t(($) => $['placeholder.select'], { ns: 'common' })}</SelectTrigger><SelectContent>diff --git a/web/app/components/workflow/nodes/list-operator/components/sub-variable-picker.tsx b/web/app/components/workflow/nodes/list-operator/components/sub-variable-picker.tsxindex b61b6aab09b..addf74d44b1 100644--- a/web/app/components/workflow/nodes/list-operator/components/sub-variable-picker.tsx+++ b/web/app/components/workflow/nodes/list-operator/components/sub-variable-picker.tsx@@ -86,7 +86,7 @@ const SubVariablePicker: FC<Props> = ({ value, onChange, className }) => {aria-hiddenclassName="mr-1.25 i-custom-vender-solid-development-variable-02 h-3.5 w-3.5 text-text-accent"/>- <SelectItemText className="mr-0 px-0 system-sm-medium text-text-secondary">+ <SelectItemText className="mr-0 system-sm-medium text-text-secondary">{option.name}</SelectItemText></div>diff --git a/web/app/components/workflow/nodes/loop/components/condition-list/condition-item.tsx b/web/app/components/workflow/nodes/loop/components/condition-list/condition-item.tsxindex f705b806922..1d4c1d10855 100644--- a/web/app/components/workflow/nodes/loop/components/condition-list/condition-item.tsx+++ b/web/app/components/workflow/nodes/loop/components/condition-list/condition-item.tsx@@ -287,7 +287,7 @@ const ConditionItem = ({aria-hiddenclassName="mr-1.25 i-custom-vender-solid-development-variable-02 h-3.5 w-3.5 text-text-accent"/>- <SelectItemText className="mr-0 px-0 system-sm-medium text-text-secondary">+ <SelectItemText className="mr-0 system-sm-medium text-text-secondary">{option.name}</SelectItemText></div>@@ -363,7 +363,7 @@ const ConditionItem = ({value={selectedSelectOption?.value ?? null}onValueChange={(value) => value && handleUpdateConditionValue(value)}>- <SelectTrigger className="h-8 rounded-t-none border-0 px-2 text-xs hover:bg-components-input-bg-normal focus-visible:bg-components-input-bg-normal">+ <SelectTrigger className="h-8 rounded-t-none border-0 pl-2 text-xs hover:bg-components-input-bg-normal focus-visible:bg-components-input-bg-normal">{selectedSelectOption?.name ?? t(($) => $['placeholder.select'], { ns: 'common' })}</SelectTrigger><SelectContent>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.tsxindex de21a0e461d..a91ee9e1f97 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@@ -77,9 +77,9 @@ const VariableTypeSelector = <T extends string>({<SelectItemkey={item}value={item}- className="h-auto gap-2 py-1.5 pr-2 pl-3 system-md-regular font-normal"+ className="h-auto gap-2 py-1.5 system-md-regular font-normal">- <SelectItemText className="px-0 system-md-regular text-text-secondary">+ <SelectItemText className="system-md-regular text-text-secondary">{item}</SelectItemText><SelectItemIndicator />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.tsxindex 9d817b252e6..36a55bd02f6 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@@ -164,7 +164,7 @@ export function AgentLogSourcePicker({className="min-h-7 grid-cols-[1fr] gap-0 px-1 py-1"render={(props, state) => (<div {...props} className={props.className}>- <ComboboxItemText className="flex min-w-0 items-center gap-2 px-0 system-sm-regular">+ <ComboboxItemText className="flex items-center gap-2 system-sm-regular"><SourceCheckbox checked={state.selected} /><LogSourceIcon source={source} /><span className="min-w-0 flex-1 truncate">{source.app_name}</span>diff --git a/web/features/skills/detail/skill-metadata.tsx b/web/features/skills/detail/skill-metadata.tsxindex cffd3a9fe00..b3d6e8544ae 100644--- a/web/features/skills/detail/skill-metadata.tsx+++ b/web/features/skills/detail/skill-metadata.tsx@@ -247,8 +247,6 @@ export function SkillTagsEditor({<ComboboxPopup className="w-(--anchor-width) min-w-60 rounded-lg border-[0.5px] border-components-panel-border bg-components-panel-bg-blur p-0 shadow-lg backdrop-blur-[5px]"><TagSearchContentViewtype="skill"- inputValue={tagSearch}- onInputValueChange={setTagSearch}canBindOrUnbindTagscanManageTagsonOpenTagManagement={() => setShowTagManagement(true)}diff --git a/web/features/tag-management/__tests__/tag-filter.spec.tsx b/web/features/tag-management/__tests__/tag-filter.spec.tsxindex 04d642f4d3b..1219a15bfa0 100644--- a/web/features/tag-management/__tests__/tag-filter.spec.tsx+++ b/web/features/tag-management/__tests__/tag-filter.spec.tsx@@ -299,30 +299,6 @@ describe('TagFilter', () => {expect(screen.getByText(i18n.noTag)).toBeInTheDocument()expect(searchInput).toHaveFocus()})-- it('should clear search and show all tags when clear icon is clicked', async () => {- const user = userEvent.setup()-- render(<TagFilter {...defaultProps} />)-- await user.click(screen.getByText(i18n.placeholder))-- const searchInput = screen.getByRole('combobox', { name: i18n.selectorPlaceholder })- await user.type(searchInput, 'Front')-- expect(screen.queryByText('Backend')).not.toBeInTheDocument()-- const clearButton = screen.getByRole('button', { name: i18n.operationClear })- clearButton.focus()- await user.keyboard('{Enter}')-- expect(searchInput).toHaveValue('')- expect(searchInput).toHaveFocus()-- expect(screen.getByText('Backend')).toBeInTheDocument()- expect(screen.getByText('Frontend')).toBeInTheDocument()- expect(screen.getByText('API Design')).toBeInTheDocument()- })})describe('Edge Cases', () => {diff --git a/web/features/tag-management/__tests__/tag-search-content.spec.tsx b/web/features/tag-management/__tests__/tag-search-content.spec.tsxindex cb4ab21e981..913e24ac11e 100644--- a/web/features/tag-management/__tests__/tag-search-content.spec.tsx+++ b/web/features/tag-management/__tests__/tag-search-content.spec.tsx@@ -109,8 +109,6 @@ const PanelHarness = ({><TagSearchContenttype={type}- inputValue={inputValue}- onInputValueChange={setInputValue}canBindOrUnbindTags={canBindOrUnbindTags}onOpenTagManagement={onOpenTagManagement}/>@@ -144,29 +142,6 @@ describe('TagSearchContent', () => {expect(screen.queryByRole('option', { name: /API/i })).not.toBeInTheDocument()})- it('clears only the search input from the input clear button', async () => {- const user = userEvent.setup()- render(<PanelHarness />)-- const input = screen.getByRole('combobox', { name: i18n.selectorPlaceholder })- await user.type(input, 'Back')- expect(input).toHaveValue('Back')- vi.clearAllMocks()-- const clearButton = screen.getByRole('button', { name: i18n.operationClear })- await user.pointer({ keys: '[MouseLeft>]', target: clearButton })- expect(input).toHaveFocus()- await user.pointer({ keys: '[/MouseLeft]', target: clearButton })-- expect(input).toHaveValue('')- expect(input).toHaveFocus()- expect(onValueChangeSpy).not.toHaveBeenCalled()- expect(screen.getByRole('option', { name: /Frontend/i })).toHaveAttribute(- 'aria-selected',- 'true',- )- })-it('shows a create option when the query is not an existing tag name', async () => {const user = userEvent.setup()render(<PanelHarness />)diff --git a/web/features/tag-management/components/tag-filter.tsx b/web/features/tag-management/components/tag-filter.tsxindex 14a3104d25a..86a40a870bc 100644--- a/web/features/tag-management/components/tag-filter.tsx+++ b/web/features/tag-management/components/tag-filter.tsx@@ -171,8 +171,6 @@ export const TagFilter = ({><TagSearchContenttype={type}- inputValue={inputValue}- onInputValueChange={setInputValue}canBindOrUnbindTagsonOpenTagManagement={onOpenTagManagement}showTagManagement={showTagManagement}diff --git a/web/features/tag-management/components/tag-search-content.tsx b/web/features/tag-management/components/tag-search-content.tsxindex ff94636a149..c422c84282b 100644--- a/web/features/tag-management/components/tag-search-content.tsx+++ b/web/features/tag-management/components/tag-search-content.tsx@@ -11,9 +11,7 @@ import {ComboboxList,ComboboxSeparator,} from '@langgenius/dify-ui/combobox'-import { IconButton } from '@langgenius/dify-ui/icon-button'import { useAtomValue } from 'jotai'-import { useRef } from 'react'import { useTranslation } from 'react-i18next'import { workspacePermissionKeysAtom } from '@/context/permission-state'import { hasPermission } from '@/utils/permission'@@ -22,8 +20,6 @@ import { isCreateTagOption } from './tag-combobox-item'type TagSearchContentProps = {type: TagType- inputValue: string- onInputValueChange: (value: string) => voidonOpenTagManagement?: () => voidonClose?: () => voidcanBindOrUnbindTags?: boolean@@ -36,8 +32,6 @@ type TagSearchContentViewProps = TagSearchContentProps & {export const TagSearchContentView = ({type,- inputValue,- onInputValueChange,onOpenTagManagement,onClose,canBindOrUnbindTags = false,@@ -45,42 +39,24 @@ export const TagSearchContentView = ({canManageTags,}: TagSearchContentViewProps) => {const { t } = useTranslation(['common'])- const inputRef = useRef<HTMLInputElement>(null)const placeholder = t(($) => $['tag.selectorPlaceholder'], { ns: 'common' }) || ''- const handleClearInput = () => {- onInputValueChange('')- inputRef.current?.focus()- }-return (<><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) {return (<ComboboxItem<string> key={tag.id} value={tag.id}>- <ComboboxItemText className="flex items-center gap-x-1 px-0">+ <ComboboxItemText className="flex items-center gap-x-1"><spanaria-hidden="true"className="i-ri-add-line size-4 shrink-0 text-text-tertiary"diff --git a/web/features/tag-management/components/tag-selector.tsx b/web/features/tag-management/components/tag-selector.tsxindex 00632dffda9..6840b1161dc 100644--- a/web/features/tag-management/components/tag-selector.tsx+++ b/web/features/tag-management/components/tag-selector.tsx@@ -288,8 +288,6 @@ export const TagSelector = ({><TagSearchContenttype={type}- inputValue={inputValue}- onInputValueChange={setInputValue}canBindOrUnbindTags={canBindOrUnbindTags}onOpenTagManagement={onOpenTagManagement}onClose={() => handleOpenChange(false)}