fix: show clear button

This commit is contained in:
chenos 2021-05-10 15:47:03 +08:00
parent 6b7e26fb90
commit 797da5bdb0

View File

@ -1,14 +1,16 @@
import React, { useState } from 'react';
import { connect } from '@formily/react-schema-renderer';
import { Popover, Button } from 'antd';
import { Popover, Button, Input } from 'antd';
import { acceptEnum, mapStyledProps, mapTextComponent } from '../shared';
import { icons, hasIcon, Icon as IconComponent } from '@/components/icons';
import { CloseOutlined } from '@ant-design/icons';
function IconField(props: any) {
const { value, onChange } = props;
const [visible, setVisible] = useState(false);
return (
<div>
<Input.Group compact>
<Popover
placement={'bottom'}
visible={visible}
@ -37,6 +39,10 @@ function IconField(props: any) {
{hasIcon(value) ? <IconComponent type={value} /> : '选择图标'}
</Button>
</Popover>
{value && <Button icon={<CloseOutlined/>} onClick={e => {
onChange(null);
}}></Button>}
</Input.Group>
</div>
);
}