fix: hidden should higher than noStyle (#26020)

This commit is contained in:
二货机器人 2020-08-05 10:08:57 +08:00 committed by GitHub
parent 683750c396
commit c345580ea2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 53 additions and 11 deletions

View File

@ -142,7 +142,7 @@ function FormItem(props: FormItemProps): React.ReactElement {
meta?: Meta, meta?: Meta,
isRequired?: boolean, isRequired?: boolean,
): React.ReactNode { ): React.ReactNode {
if (noStyle) { if (noStyle && !hidden) {
return baseChildren; return baseChildren;
} }

View File

@ -1,6 +1,35 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Form Form item hidden 1`] = ` exports[`Form Form item hidden noStyle should not work when hidden 1`] = `
<form
class="ant-form ant-form-horizontal"
>
<div
class="ant-row ant-form-item ant-form-item-hidden"
>
<div
class="ant-col ant-form-item-control"
>
<div
class="ant-form-item-control-input"
>
<div
class="ant-form-item-control-input-content"
>
<input
class="ant-input"
id="light"
type="text"
value=""
/>
</div>
</div>
</div>
</div>
</form>
`;
exports[`Form Form item hidden should work 1`] = `
<form <form
class="ant-form ant-form-horizontal" class="ant-form ant-form-horizontal"
> >

View File

@ -699,7 +699,8 @@ describe('Form', () => {
expect(wrapper.find('input').prop('onBlur')).toBeTruthy(); expect(wrapper.find('input').prop('onBlur')).toBeTruthy();
}); });
it('Form item hidden', () => { describe('Form item hidden', () => {
it('should work', () => {
const wrapper = mount( const wrapper = mount(
<Form> <Form>
<Form.Item name="light" hidden> <Form.Item name="light" hidden>
@ -709,4 +710,16 @@ describe('Form', () => {
); );
expect(wrapper).toMatchRenderedSnapshot(); expect(wrapper).toMatchRenderedSnapshot();
}); });
it('noStyle should not work when hidden', () => {
const wrapper = mount(
<Form>
<Form.Item name="light" hidden noStyle>
<Input />
</Form.Item>
</Form>,
);
expect(wrapper).toMatchRenderedSnapshot();
});
});
}); });