feat: add preserveExternalSelection prop to various components for improved selection handling
This commit is contained in:
@@ -241,6 +241,7 @@ export function ConditionBranchConfigPanel({
|
|||||||
options={targetOptions}
|
options={targetOptions}
|
||||||
placeholder="选择目标节点"
|
placeholder="选择目标节点"
|
||||||
triggerClassName={inspectorComboboxClassName}
|
triggerClassName={inspectorComboboxClassName}
|
||||||
|
preserveExternalSelection
|
||||||
onChange={(targetNodeId) => updateBranch({ ...branch, targetNodeId })}
|
onChange={(targetNodeId) => updateBranch({ ...branch, targetNodeId })}
|
||||||
/>
|
/>
|
||||||
</InspectorRow>
|
</InspectorRow>
|
||||||
@@ -346,6 +347,7 @@ function ConditionBranchesEditor({
|
|||||||
options={targetOptions}
|
options={targetOptions}
|
||||||
placeholder="选择目标节点"
|
placeholder="选择目标节点"
|
||||||
triggerClassName={inspectorComboboxClassName}
|
triggerClassName={inspectorComboboxClassName}
|
||||||
|
preserveExternalSelection
|
||||||
onChange={(targetNodeId) => onChange({ ...branch, targetNodeId })}
|
onChange={(targetNodeId) => onChange({ ...branch, targetNodeId })}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -418,6 +420,7 @@ function ConditionFields({
|
|||||||
options={CONDITION_OPERATOR_OPTIONS}
|
options={CONDITION_OPERATOR_OPTIONS}
|
||||||
placeholder="选择操作符"
|
placeholder="选择操作符"
|
||||||
triggerClassName={inspectorComboboxClassName}
|
triggerClassName={inspectorComboboxClassName}
|
||||||
|
preserveExternalSelection
|
||||||
onChange={(operator) => onChange({
|
onChange={(operator) => onChange({
|
||||||
...branch,
|
...branch,
|
||||||
condition: { ...condition, operator },
|
condition: { ...condition, operator },
|
||||||
@@ -435,6 +438,7 @@ function ConditionFields({
|
|||||||
}))}
|
}))}
|
||||||
placeholder="选择取值"
|
placeholder="选择取值"
|
||||||
triggerClassName={inspectorComboboxClassName}
|
triggerClassName={inspectorComboboxClassName}
|
||||||
|
preserveExternalSelection
|
||||||
onChange={(nextValue) => {
|
onChange={(nextValue) => {
|
||||||
const selectedOption = valueOptions.find((option) => stringifyConditionRight(option.value) === nextValue)
|
const selectedOption = valueOptions.find((option) => stringifyConditionRight(option.value) === nextValue)
|
||||||
onChange({
|
onChange({
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ export function VariableSelector({
|
|||||||
options={options}
|
options={options}
|
||||||
placeholder={placeholder}
|
placeholder={placeholder}
|
||||||
triggerClassName={triggerClassName}
|
triggerClassName={triggerClassName}
|
||||||
|
preserveExternalSelection
|
||||||
onChange={(next) => {
|
onChange={(next) => {
|
||||||
const variable = variables.find((item) => `${item.nodeId}.${item.field}` === next)
|
const variable = variables.find((item) => `${item.nodeId}.${item.field}` === next)
|
||||||
if (variable) {
|
if (variable) {
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ type OptionComboboxProps = {
|
|||||||
emptyText?: string
|
emptyText?: string
|
||||||
disabled?: boolean
|
disabled?: boolean
|
||||||
triggerClassName?: string
|
triggerClassName?: string
|
||||||
|
preserveExternalSelection?: boolean
|
||||||
onChange: (value: string) => void
|
onChange: (value: string) => void
|
||||||
renderOptionAction?: (option: ComboboxOption) => ReactNode
|
renderOptionAction?: (option: ComboboxOption) => ReactNode
|
||||||
}
|
}
|
||||||
@@ -47,6 +48,7 @@ export function OptionCombobox({
|
|||||||
emptyText,
|
emptyText,
|
||||||
disabled = false,
|
disabled = false,
|
||||||
triggerClassName,
|
triggerClassName,
|
||||||
|
preserveExternalSelection = false,
|
||||||
onChange,
|
onChange,
|
||||||
renderOptionAction,
|
renderOptionAction,
|
||||||
}: OptionComboboxProps) {
|
}: OptionComboboxProps) {
|
||||||
@@ -70,7 +72,11 @@ export function OptionCombobox({
|
|||||||
<span className="truncate">{selectedLabel}</span>
|
<span className="truncate">{selectedLabel}</span>
|
||||||
<ChevronsUpDownIcon className="ml-2 size-4 shrink-0 opacity-50" />
|
<ChevronsUpDownIcon className="ml-2 size-4 shrink-0 opacity-50" />
|
||||||
</PopoverTrigger>
|
</PopoverTrigger>
|
||||||
<PopoverContent className="w-(--radix-popover-trigger-width) p-0" align="start">
|
<PopoverContent
|
||||||
|
className="w-(--radix-popover-trigger-width) p-0"
|
||||||
|
align="start"
|
||||||
|
data-workflow-preserve-selection={preserveExternalSelection ? true : undefined}
|
||||||
|
>
|
||||||
<Command>
|
<Command>
|
||||||
<CommandInput placeholder={searchPlaceholder ?? t("common.searchKeyword")} />
|
<CommandInput placeholder={searchPlaceholder ?? t("common.searchKeyword")} />
|
||||||
<CommandList>
|
<CommandList>
|
||||||
|
|||||||
Reference in New Issue
Block a user