mirror of
https://gitee.com/nocobase/nocobase.git
synced 2024-12-03 04:38:15 +08:00
fix(plugin-workflow): fix empty value in create and update node association values (#4433)
This commit is contained in:
parent
7b8a86350a
commit
0a6df92159
@ -21,7 +21,7 @@ import {
|
||||
useToken,
|
||||
} from '@nocobase/client';
|
||||
import { Button, Dropdown, Form, Input, MenuProps } from 'antd';
|
||||
import React, { useMemo } from 'react';
|
||||
import React, { useCallback, useMemo } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { lang } from '../locale';
|
||||
import { useWorkflowVariableOptions } from '../variable';
|
||||
@ -36,10 +36,20 @@ function AssociationInput(props) {
|
||||
const { type } = fields.find((item) => item.name === fieldName);
|
||||
|
||||
const value = Array.isArray(props.value) ? props.value.join(',') : props.value;
|
||||
function onChange(ev) {
|
||||
const onChange = useCallback(
|
||||
(ev) => {
|
||||
const trimed = ev.target.value.trim();
|
||||
props.onChange(['belongsTo', 'hasOne'].includes(type) ? trimed : trimed.split(/[,\s]+/));
|
||||
}
|
||||
const next = ['belongsTo', 'hasOne'].includes(type)
|
||||
? trimed || null
|
||||
: trimed
|
||||
.split(',')
|
||||
.map((item) => item.trim())
|
||||
.filter((item) => item !== '');
|
||||
props.onChange(next);
|
||||
},
|
||||
[props.onChange, type],
|
||||
);
|
||||
|
||||
return <Input {...props} value={value} onChange={onChange} />;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user