Skip to content

Commit

Permalink
fix: 修复 combo nullable 清空失败的问题 (baidu#9414)
Browse files Browse the repository at this point in the history
  • Loading branch information
2betop committed Jan 12, 2024
1 parent 0628726 commit bddf9d1
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/amis/src/renderers/Form/Combo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import {
import {ListenerAction} from 'amis-core';
import type {SchemaTokenizeableString} from '../../Schema';
import isPlainObject from 'lodash/isPlainObject';
import isEqual from 'lodash/isEqual';

export type ComboCondition = {
test: string;
Expand Down Expand Up @@ -798,6 +799,11 @@ export default class ComboControl extends React.Component<ComboProps> {
}

handleSingleFormChange(values: object) {
if (this.props.value === null && isEqual(this.defaultValue, values)) {
// 由清空触发,忽略
return;
}

this.props.onChange(
{
...values
Expand Down Expand Up @@ -1713,7 +1719,9 @@ export default class ComboControl extends React.Component<ComboProps> {
} = this.props;

let items = this.props.items;
const data = isObject(value) ? this.formatValue(value) : this.defaultValue;
const data = isObject(value)
? this.formatValue(value)
: this.formatValue(this.defaultValue);
let condition: ComboCondition | null = null;

if (Array.isArray(conditions) && conditions.length) {
Expand Down

0 comments on commit bddf9d1

Please sign in to comment.