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: Form item has default height align with form size #21476

Merged
merged 3 commits into from Feb 19, 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
884 changes: 456 additions & 428 deletions components/auto-complete/__tests__/__snapshots__/demo.test.js.snap

Large diffs are not rendered by default.

30 changes: 19 additions & 11 deletions components/comment/__tests__/__snapshots__/demo.test.js.snap
Expand Up @@ -160,10 +160,14 @@ exports[`renders ./components/comment/demo/editor.md correctly 1`] = `
<div
class="ant-form-item-control-input"
>
<textarea
class="ant-input"
rows="4"
/>
<div
class="ant-form-item-control-input-content"
>
<textarea
class="ant-input"
rows="4"
/>
</div>
</div>
</div>
</div>
Expand All @@ -176,14 +180,18 @@ exports[`renders ./components/comment/demo/editor.md correctly 1`] = `
<div
class="ant-form-item-control-input"
>
<button
class="ant-btn ant-btn-primary"
type="submit"
<div
class="ant-form-item-control-input-content"
>
<span>
Add Comment
</span>
</button>
<button
class="ant-btn ant-btn-primary"
type="submit"
>
<span>
Add Comment
</span>
</button>
</div>
</div>
</div>
</div>
Expand Down
Expand Up @@ -6979,11 +6979,15 @@ exports[`ConfigProvider components Form configProvider 1`] = `
<div
class="config-form-item-control-input"
>
<input
class="config-input"
type="text"
value=""
/>
<div
class="config-form-item-control-input-content"
>
<input
class="config-input"
type="text"
value=""
/>
</div>
</div>
<div
class="config-form-item-explain"
Expand All @@ -7010,11 +7014,15 @@ exports[`ConfigProvider components Form normal 1`] = `
<div
class="ant-form-item-control-input"
>
<input
class="ant-input"
type="text"
value=""
/>
<div
class="ant-form-item-control-input-content"
>
<input
class="ant-input"
type="text"
value=""
/>
</div>
</div>
<div
class="ant-form-item-explain"
Expand All @@ -7041,11 +7049,15 @@ exports[`ConfigProvider components Form prefixCls 1`] = `
<div
class="prefix-Form-item-control-input"
>
<input
class="prefix-Form"
type="text"
value=""
/>
<div
class="prefix-Form-item-control-input-content"
>
<input
class="prefix-Form"
type="text"
value=""
/>
</div>
</div>
<div
class="prefix-Form-item-explain"
Expand Down
6 changes: 4 additions & 2 deletions components/form/Form.tsx
Expand Up @@ -8,7 +8,7 @@ import { ConfigContext, ConfigConsumerProps } from '../config-provider';
import { FormContext } from './context';
import { FormLabelAlign } from './interface';
import { useForm, FormInstance } from './util';
import { SizeType, SizeContextProvider } from '../config-provider/SizeContext';
import SizeContext, { SizeType, SizeContextProvider } from '../config-provider/SizeContext';

export type FormLayout = 'horizontal' | 'inline' | 'vertical';

Expand All @@ -26,6 +26,7 @@ export interface FormProps extends Omit<RcFormProps, 'form'> {
}

const InternalForm: React.FC<FormProps> = (props, ref) => {
const contextSize = React.useContext(SizeContext);
const { getPrefixCls, direction }: ConfigConsumerProps = React.useContext(ConfigContext);

const {
Expand All @@ -39,7 +40,7 @@ const InternalForm: React.FC<FormProps> = (props, ref) => {
hideRequiredMark,
className = '',
layout = 'horizontal',
size,
size = contextSize,
} = props;
const prefixCls = getPrefixCls('form', customizePrefixCls);

Expand All @@ -49,6 +50,7 @@ const InternalForm: React.FC<FormProps> = (props, ref) => {
[`${prefixCls}-${layout}`]: true,
[`${prefixCls}-hide-required-mark`]: hideRequiredMark,
[`${prefixCls}-rtl`]: direction === 'rtl',
[`${prefixCls}-${size}`]: size,
},
className,
);
Expand Down
2 changes: 1 addition & 1 deletion components/form/FormItemInput.tsx
Expand Up @@ -92,7 +92,7 @@ const FormItemInput: React.FC<FormItemInputProps & FormItemInputMiscProps> = ({
<FormContext.Provider value={subFormContext}>
<Col {...mergedWrapperCol} className={className}>
<div className={`${baseClassName}-control-input`}>
{children}
<div className={`${baseClassName}-control-input-content`}>{children}</div>
{icon}
</div>
<CSSMotion
Expand Down