Commit 1a43142252328adf1d0870e8e406f7d0fa70af65

Authored by George Tan
Committed by GitHub
1 parent 52e295f1

fix(form component): fix form 'vertical' layout row width (#1535)

src/components/Form/src/hooks/useLabelWidth.ts
1 import type { Ref } from 'vue'; 1 import type { Ref } from 'vue';
2 -import type { FormProps, FormSchema } from '../types/form';  
3 -  
4 import { computed, unref } from 'vue'; 2 import { computed, unref } from 'vue';
  3 +import type { FormProps, FormSchema } from '../types/form';
5 import { isNumber } from '/@/utils/is'; 4 import { isNumber } from '/@/utils/is';
6 5
7 export function useItemLabelWidth(schemaItemRef: Ref<FormSchema>, propsRef: Ref<FormProps>) { 6 export function useItemLabelWidth(schemaItemRef: Ref<FormSchema>, propsRef: Ref<FormProps>) {
@@ -14,6 +13,7 @@ export function useItemLabelWidth(schemaItemRef: Ref&lt;FormSchema&gt;, propsRef: Ref&lt; @@ -14,6 +13,7 @@ export function useItemLabelWidth(schemaItemRef: Ref&lt;FormSchema&gt;, propsRef: Ref&lt;
14 labelWidth: globalLabelWidth, 13 labelWidth: globalLabelWidth,
15 labelCol: globalLabelCol, 14 labelCol: globalLabelCol,
16 wrapperCol: globWrapperCol, 15 wrapperCol: globWrapperCol,
  16 + layout,
17 } = unref(propsRef); 17 } = unref(propsRef);
18 18
19 // If labelWidth is set globally, all items setting 19 // If labelWidth is set globally, all items setting
@@ -33,7 +33,10 @@ export function useItemLabelWidth(schemaItemRef: Ref&lt;FormSchema&gt;, propsRef: Ref&lt; @@ -33,7 +33,10 @@ export function useItemLabelWidth(schemaItemRef: Ref&lt;FormSchema&gt;, propsRef: Ref&lt;
33 33
34 return { 34 return {
35 labelCol: { style: { width }, ...col }, 35 labelCol: { style: { width }, ...col },
36 - wrapperCol: { style: { width: `calc(100% - ${width})` }, ...wrapCol }, 36 + wrapperCol: {
  37 + style: { width: layout === 'vertical' ? '100%' : `calc(100% - ${width})` },
  38 + ...wrapCol,
  39 + },
37 }; 40 };
38 }); 41 });
39 } 42 }