Skip to content

Commit

Permalink
enhance: (List) adjust the disabled logic so that every field compone…
Browse files Browse the repository at this point in the history
…nt can be disabled
  • Loading branch information
awmleer committed Oct 20, 2021
1 parent 94b0b7d commit d665d6d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 14 deletions.
5 changes: 0 additions & 5 deletions src/components/form/form-item.less
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@
color: var(--adm-color-danger);
user-select: none;
}

&-disable {
color: #666;
opacity: 0.4;
}
}

&-footer {
Expand Down
11 changes: 2 additions & 9 deletions src/components/form/form-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,11 @@ const FormItemLayout: React.FC<FormItemLayoutProps> = props => {
const hasFeedback = props.hasFeedback || context.hasFeedback
const layout = props.layout || context.layout

const formItemLabelClass = classNames(`${classPrefix}-label`, {
[`${classPrefix}-label-disable`]: disabled,
})

const feedback =
hasFeedback && meta && meta.errors.length > 0 ? meta.errors[0] : null

const labelElement = label ? (
<label className={formItemLabelClass} htmlFor={htmlFor}>
<label className={`${classPrefix}-label`} htmlFor={htmlFor}>
{label}
{required && <span className={`${classPrefix}-label-required`}>*</span>}
{help && <span className={`${classPrefix}-label-help`}>{help}</span>}
Expand All @@ -109,6 +105,7 @@ const FormItemLayout: React.FC<FormItemLayoutProps> = props => {
className={classNames(classPrefix, className, {
[`${classPrefix}-hidden`]: hidden,
})}
disabled={disabled}
onClick={props.disabled ? undefined : props.onClick}
>
{children}
Expand Down Expand Up @@ -267,10 +264,6 @@ export const FormItem: FC<FormItemProps> = props => {
childProps.id = fieldId
}

if (disabled) {
childProps.disabled = disabled
}

// We should keep user origin event handler
const triggers = new Set<string>([
...toArray(trigger),
Expand Down

0 comments on commit d665d6d

Please sign in to comment.