Browse Source

fix: Form layout span 24 usage (#32981)

close #32980
pull/32999/head
afc163 3 years ago
committed by GitHub
parent
commit
37442ae0d5
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 131
      components/form/__tests__/__snapshots__/demo.test.js.snap
  2. 65
      components/form/demo/col-24-debug.md
  3. 3
      components/form/style/horizontal.less

131
components/form/__tests__/__snapshots__/demo.test.js.snap

@ -471,6 +471,137 @@ exports[`renders ./components/form/demo/basic.md correctly 1`] = `
</form>
`;
exports[`renders ./components/form/demo/col-24-debug.md correctly 1`] = `
<form
autocomplete="off"
class="ant-form ant-form-horizontal"
id="basic"
>
<div
class="ant-row ant-form-item"
>
<div
class="ant-col ant-col-24 ant-form-item-label"
>
<label
class="ant-form-item-required"
for="basic_username"
title="Username"
>
Username
</label>
</div>
<div
class="ant-col ant-col-24 ant-form-item-control"
>
<div
class="ant-form-item-control-input"
>
<div
class="ant-form-item-control-input-content"
>
<input
class="ant-input"
id="basic_username"
type="text"
value=""
/>
</div>
</div>
</div>
</div>
<div
class="ant-row ant-form-item"
>
<div
class="ant-col ant-col-24 ant-form-item-label"
>
<label
class="ant-form-item-required"
for="basic_password"
title="Password"
>
Password
</label>
</div>
<div
class="ant-col ant-col-24 ant-form-item-control"
>
<div
class="ant-form-item-control-input"
>
<div
class="ant-form-item-control-input-content"
>
<span
class="ant-input-affix-wrapper ant-input-password"
>
<input
action="click"
class="ant-input"
id="basic_password"
type="password"
value=""
/>
<span
class="ant-input-suffix"
>
<span
aria-label="eye-invisible"
class="anticon anticon-eye-invisible ant-input-password-icon"
role="img"
tabindex="-1"
>
<svg
aria-hidden="true"
data-icon="eye-invisible"
fill="currentColor"
focusable="false"
height="1em"
viewBox="64 64 896 896"
width="1em"
>
<path
d="M942.2 486.2Q889.47 375.11 816.7 305l-50.88 50.88C807.31 395.53 843.45 447.4 874.7 512 791.5 684.2 673.4 766 512 766q-72.67 0-133.87-22.38L323 798.75Q408 838 512 838q288.3 0 430.2-300.3a60.29 60.29 0 000-51.5zm-63.57-320.64L836 122.88a8 8 0 00-11.32 0L715.31 232.2Q624.86 186 512 186q-288.3 0-430.2 300.3a60.3 60.3 0 000 51.5q56.69 119.4 136.5 191.41L112.48 835a8 8 0 000 11.31L155.17 889a8 8 0 0011.31 0l712.15-712.12a8 8 0 000-11.32zM149.3 512C232.6 339.8 350.7 258 512 258c54.54 0 104.13 9.36 149.12 28.39l-70.3 70.3a176 176 0 00-238.13 238.13l-83.42 83.42C223.1 637.49 183.3 582.28 149.3 512zm246.7 0a112.11 112.11 0 01146.2-106.69L401.31 546.2A112 112 0 01396 512z"
/>
<path
d="M508 624c-3.46 0-6.87-.16-10.25-.47l-52.82 52.82a176.09 176.09 0 00227.42-227.42l-52.82 52.82c.31 3.38.47 6.79.47 10.25a111.94 111.94 0 01-112 112z"
/>
</svg>
</span>
</span>
</span>
</div>
</div>
</div>
</div>
<div
class="ant-row ant-form-item"
>
<div
class="ant-col ant-col-24 ant-form-item-control"
>
<div
class="ant-form-item-control-input"
>
<div
class="ant-form-item-control-input-content"
>
<button
class="ant-btn ant-btn-primary"
type="submit"
>
<span>
Submit
</span>
</button>
</div>
</div>
</div>
</div>
</form>
`;
exports[`renders ./components/form/demo/control-hooks.md correctly 1`] = `
<form
class="ant-form ant-form-horizontal"

65
components/form/demo/col-24-debug.md

@ -0,0 +1,65 @@
---
order: 9999
title:
zh-CN: 测试特殊 col 24 用法
en-US: Test col 24 usage
debug: true
---
## zh-CN
See issue [#32980](https://github.com/ant-design/ant-design/issues/32980).
## en-US
See issue [#32980](https://github.com/ant-design/ant-design/issues/32980).
```tsx
import { Form, Input, Button } from 'antd';
const Demo = () => {
const onFinish = (values: any) => {
console.log('Success:', values);
};
const onFinishFailed = (errorInfo: any) => {
console.log('Failed:', errorInfo);
};
return (
<Form
name="basic"
labelCol={{ span: 24 }}
wrapperCol={{ span: 24 }}
initialValues={{ remember: true }}
onFinish={onFinish}
onFinishFailed={onFinishFailed}
autoComplete="off"
>
<Form.Item
label="Username"
name="username"
rules={[{ required: true, message: 'Please input your username!' }]}
>
<Input />
</Form.Item>
<Form.Item
label="Password"
name="password"
rules={[{ required: true, message: 'Please input your password!' }]}
>
<Input.Password />
</Form.Item>
<Form.Item>
<Button type="primary" htmlType="submit">
Submit
</Button>
</Form.Item>
</Form>
);
};
ReactDOM.render(<Demo />, mountNode);
```

3
components/form/style/horizontal.less

@ -9,6 +9,9 @@
}
.@{form-item-prefix-cls}-control {
flex: 1 1 0;
}
// https://github.com/ant-design/ant-design/issues/32980
.@{form-item-prefix-cls}-control:not(.@{ant-prefix}-col) {
// https://github.com/ant-design/ant-design/issues/32777
min-width: 0;
}

Loading…
Cancel
Save