Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix warning in Field components #8158

Merged
merged 1 commit into from
Sep 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/ra-ui-materialui/src/field/BooleanField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export const BooleanField: FunctionComponent<BooleanFieldProps> = memo(
className={className}
{...sanitizeFieldRestProps(rest)}
>
{translate(emptyText, { _: emptyText })}
{emptyText && translate(emptyText, { _: emptyText })}
</Typography>
);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/ra-ui-materialui/src/field/ChipField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const ChipField: FC<ChipFieldProps> = memo(props => {
className={className}
{...sanitizeFieldRestProps(rest)}
>
{translate(emptyText, { _: emptyText })}
{emptyText && translate(emptyText, { _: emptyText })}
</Typography>
);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/ra-ui-materialui/src/field/DateField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export const DateField: FC<DateFieldProps> = memo(props => {
className={className}
{...sanitizeFieldRestProps(rest)}
>
{translate(emptyText, { _: emptyText })}
{emptyText && translate(emptyText, { _: emptyText })}
</Typography>
) : null;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/ra-ui-materialui/src/field/EmailField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const EmailField: FC<EmailFieldProps> = memo(props => {
className={className}
{...sanitizeFieldRestProps(rest)}
>
{translate(emptyText, { _: emptyText })}
{emptyText && translate(emptyText, { _: emptyText })}
</Typography>
) : null;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/ra-ui-materialui/src/field/FileField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const FileField = (props: FileFieldProps) => {
className={className}
{...sanitizeFieldRestProps(rest)}
>
{translate(emptyText, { _: emptyText })}
{emptyText && translate(emptyText, { _: emptyText })}
</Typography>
) : (
<Root className={className} {...sanitizeFieldRestProps(rest)} />
Expand Down
2 changes: 1 addition & 1 deletion packages/ra-ui-materialui/src/field/ImageField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const ImageField = (props: ImageFieldProps) => {
className={className}
{...sanitizeFieldRestProps(rest)}
>
{translate(emptyText, { _: emptyText })}
{emptyText && translate(emptyText, { _: emptyText })}
</Typography>
) : (
<div className={className} {...sanitizeFieldRestProps(rest)} />
Expand Down
2 changes: 1 addition & 1 deletion packages/ra-ui-materialui/src/field/NumberField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export const NumberField: FC<NumberFieldProps> = memo(props => {
className={className}
{...sanitizeFieldRestProps(rest)}
>
{translate(emptyText, { _: emptyText })}
{emptyText && translate(emptyText, { _: emptyText })}
</Typography>
) : null;
}
Expand Down
6 changes: 4 additions & 2 deletions packages/ra-ui-materialui/src/field/ReferenceField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export const ReferenceField: FC<ReferenceFieldProps> = props => {
return id == null ? (
emptyText ? (
<Typography component="span" variant="body2">
{translate(emptyText, { _: emptyText })}
{emptyText && translate(emptyText, { _: emptyText })}
</Typography>
) : null
) : (
Expand Down Expand Up @@ -184,7 +184,9 @@ export const ReferenceFieldView: FC<ReferenceFieldViewProps> = props => {
return <LinearProgress />;
}
if (!referenceRecord) {
return emptyText ? <>{translate(emptyText, { _: emptyText })}</> : null;
return emptyText ? (
<>{emptyText && translate(emptyText, { _: emptyText })}</>
) : null;
}

let child = children || (
Expand Down
2 changes: 1 addition & 1 deletion packages/ra-ui-materialui/src/field/ReferenceOneField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export const ReferenceOneField = (props: ReferenceOneFieldProps) => {
return !record || (!isLoading && referenceRecord == null) ? (
emptyText ? (
<Typography component="span" variant="body2">
{translate(emptyText, { _: emptyText })}
{emptyText && translate(emptyText, { _: emptyText })}
</Typography>
) : null
) : (
Expand Down
2 changes: 1 addition & 1 deletion packages/ra-ui-materialui/src/field/SelectField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export const SelectField: FC<SelectFieldProps> = memo(props => {
className={className}
{...sanitizeFieldRestProps(rest)}
>
{translate(emptyText, { _: emptyText })}
{emptyText && translate(emptyText, { _: emptyText })}
</Typography>
) : null;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/ra-ui-materialui/src/field/UrlField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const UrlField: FC<UrlFieldProps> = memo(props => {
className={className}
{...sanitizeFieldRestProps(rest)}
>
{translate(emptyText, { _: emptyText })}
{emptyText && translate(emptyText, { _: emptyText })}
</Typography>
);
}
Expand Down