mirror of
https://github.com/element-plus/element-plus.git
synced 2025-08-26 04:27:26 +08:00
fix(components): [form] no margin when there is no label (#9940)
This commit is contained in:
@ -133,7 +133,7 @@ form/accessibility
|
||||
| `label-position` | Position of label. If set to `'left'` or `'right'`, `label-width` prop is also required. | `'left' \| 'right' \| 'top'` | `'right'` |
|
||||
| `label-width` | Width of label, e.g. `'50px'`. All its direct child form items will inherit this value. `auto` is supported. | `string \| number` | — |
|
||||
| `label-suffix` | Suffix of the label. | `string` | — |
|
||||
| `hide-required-asterisk` | Whether to hide required fields should have a red asterisk (star) beside their labels. | `boolean` | `false` |
|
||||
| `hide-required-asterisk` | Whether to hide required fields should have a red asterisk (star) beside their labels. | `boolean` | `false` |
|
||||
| `require-asterisk-position` | Position of asterisk. | `'left' \| 'right'` | `'left'` |
|
||||
| `show-message` | Whether to show the error message. | `boolean` | `true` |
|
||||
| `inline-message` | Whether to display the error message inline with the form item. | `boolean` | `false` |
|
||||
|
@ -377,6 +377,7 @@ const context: FormItemContext = reactive({
|
||||
labelId,
|
||||
inputIds,
|
||||
isGroup,
|
||||
hasLabel,
|
||||
addInputId,
|
||||
removeInputId,
|
||||
resetField,
|
||||
|
@ -88,8 +88,9 @@ export default defineComponent({
|
||||
const { isAutoWidth } = props
|
||||
if (isAutoWidth) {
|
||||
const autoLabelWidth = formContext?.autoLabelWidth
|
||||
const hasLabel = formItemContext?.hasLabel
|
||||
const style: CSSProperties = {}
|
||||
if (autoLabelWidth && autoLabelWidth !== 'auto') {
|
||||
if (hasLabel && autoLabelWidth && autoLabelWidth !== 'auto') {
|
||||
const marginWidth = Math.max(
|
||||
0,
|
||||
Number.parseInt(autoLabelWidth, 10) - computedWidth.value
|
||||
|
@ -52,6 +52,7 @@ export interface FormItemContext extends FormItemProps {
|
||||
isGroup: boolean
|
||||
labelId: string
|
||||
inputIds: string[]
|
||||
hasLabel: boolean
|
||||
addInputId: (id: string) => void
|
||||
removeInputId: (id: string) => void
|
||||
validate: (
|
||||
|
Reference in New Issue
Block a user