Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: hidden should higher than noStyle #26020

Merged
merged 2 commits into from Aug 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/form/FormItem.tsx
Expand Up @@ -142,7 +142,7 @@ function FormItem(props: FormItemProps): React.ReactElement {
meta?: Meta,
isRequired?: boolean,
): React.ReactNode {
if (noStyle) {
if (noStyle && !hidden) {
return baseChildren;
}

Expand Down
31 changes: 30 additions & 1 deletion components/form/__tests__/__snapshots__/index.test.js.snap
@@ -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"
>
Expand Down
31 changes: 22 additions & 9 deletions components/form/__tests__/index.test.js
Expand Up @@ -699,14 +699,27 @@ describe('Form', () => {
expect(wrapper.find('input').prop('onBlur')).toBeTruthy();
});

it('Form item hidden', () => {
const wrapper = mount(
<Form>
<Form.Item name="light" hidden>
<Input />
</Form.Item>
</Form>,
);
expect(wrapper).toMatchRenderedSnapshot();
describe('Form item hidden', () => {
it('should work', () => {
const wrapper = mount(
<Form>
<Form.Item name="light" hidden>
<Input />
</Form.Item>
</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();
});
});
});