Skip to content

Commit

Permalink
fix: ensure AutoField respects readOnly styles
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisvxd committed Oct 7, 2024
1 parent ea045f8 commit 9ffe817
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions packages/core/components/AutoField/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -222,12 +222,21 @@ export function AutoFieldPrivate<
return <AutoFieldInternal<ValueType, FieldType> {...props} {...localProps} />;
}

const DefaultLabel = (props: any) => <div {...props} />;

export function AutoField<
ValueType = any,
FieldType extends Field<ValueType> = Field<ValueType>
>(props: FieldProps<ValueType, FieldType>) {
const DefaultLabel = useMemo(() => {
const DefaultLabel = (labelProps: any) => (
<div
{...labelProps}
className={getClassName({ readOnly: props.readOnly })}
/>
);

return DefaultLabel;
}, [props.readOnly]);

return (
<AutoFieldInternal<ValueType, FieldType> {...props} Label={DefaultLabel} />
);
Expand Down

0 comments on commit 9ffe817

Please sign in to comment.