Skip to content

Commit f44ae0e

Browse files
Samtarobirkir
authored andcommitted
fix: allow document selector to be cleared (#274)
1 parent 805e5e6 commit f44ae0e

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

packages/prime-field-document/src/ui/InputComponent.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { PrimeFieldProps } from '@primecms/field';
22
import { Form, TreeSelect } from 'antd';
33
import React from 'react';
4+
import { get } from 'lodash';
45

56
interface IContentType {
67
documentId: string;
@@ -94,6 +95,7 @@ export class InputComponent extends React.Component<PrimeFieldProps, IState> {
9495
const { loading, options } = this.state;
9596
const { field, document, path, form, initialValue } = this.props;
9697
const { getFieldDecorator } = form;
98+
const required = get(field.options, 'required', false);
9799

98100
return (
99101
<Form.Item label={field.title}>
@@ -110,6 +112,7 @@ export class InputComponent extends React.Component<PrimeFieldProps, IState> {
110112
multiple={field.options.multiple || false}
111113
treeNodeFilterProp="title"
112114
onChange={this.onChange}
115+
allowClear={!required}
113116
/>
114117
) : null}
115118
{getFieldDecorator(path, {

0 commit comments

Comments
 (0)