Skip to content

Commit 1bd47cf

Browse files
committed
Fix form error style for input addonAfter slot (vueComponent#6374)
* fix(FormITem): add one propType, add disableElement,edit style
1 parent b16c89f commit 1bd47cf

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

components/form/FormItem.tsx

+6-1
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ export const formItemProps = () => ({
102102
messageVariables: { type: Object as PropType<Record<string, string>> },
103103
hidden: Boolean,
104104
noStyle: Boolean,
105+
disabled: Boolean,
105106
});
106107

107108
export type FormItemProps = Partial<ExtractPropTypes<ReturnType<typeof formItemProps>>>;
@@ -250,7 +251,9 @@ export default defineComponent({
250251
);
251252
validateState.value = 'validating';
252253
errors.value = [];
253-
254+
if (props.disabled) {
255+
return Promise.resolve();
256+
}
254257
promise
255258
.catch(e => e)
256259
.then((results: RuleError[] = []) => {
@@ -408,6 +411,8 @@ export default defineComponent({
408411
v-slots={{
409412
default: () => (
410413
<>
414+
{/* disable */}
415+
{props.disabled ? <div class={[`${prefixCls.value}-item-disabled`]}></div> : ''}
411416
{/* Label */}
412417
<FormItemLabel
413418
{...props}

components/form/style/index.less

+14-2
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
// ================================================================
6060
.@{form-item-prefix-cls} {
6161
.reset-component();
62-
62+
position: relative;
6363
margin-bottom: @form-item-margin-bottom;
6464
vertical-align: top;
6565

@@ -74,6 +74,16 @@
7474
display: none;
7575
}
7676

77+
&-disabled {
78+
//https://github.com/vueComponent/ant-design-vue/issues/6374
79+
.disabled();
80+
width: 100%;
81+
height: 100%;
82+
z-index: 99;
83+
position: absolute;
84+
background: none;
85+
}
86+
7787
// ==============================================================
7888
// = Label =
7989
// ==============================================================
@@ -110,7 +120,9 @@
110120
}
111121

112122
// Required mark
113-
&.@{form-item-prefix-cls}-required:not(.@{form-item-prefix-cls}-required-mark-optional)::before {
123+
&.@{form-item-prefix-cls}-required:not(
124+
.@{form-item-prefix-cls}-required-mark-optional
125+
)::before {
114126
display: inline-block;
115127
margin-right: 4px;
116128
color: @label-required-color;

0 commit comments

Comments
 (0)