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,
isRequired?: boolean,
): React.ReactNode {
if (noStyle) {
if (noStyle && !hidden) {
return baseChildren;
}

View File

@ -1,6 +1,35 @@
// 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
class="ant-form ant-form-horizontal"
>

View File

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