mirror of
https://github.com/nocobase/nocobase
synced 2024-11-15 07:57:20 +00: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 trimed = ev.target.value.trim();
|
||||
props.onChange(['belongsTo', 'hasOne'].includes(type) ? trimed : trimed.split(/[,\s]+/));
|
||||
}
|
||||
const onChange = useCallback(
|
||||
(ev) => {
|
||||
const trimed = ev.target.value.trim();
|
||||
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