Skip to content

Commit 6463e7a

Browse files
committed
Fix FileFIeld and ImageField
1 parent 69e46f8 commit 6463e7a

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

packages/ra-ui-materialui/src/field/FileField.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export const FileField = <
4141
...rest
4242
} = props;
4343
const record = useRecordContext(props);
44-
const sourceValue = get(record, source).toString();
44+
const sourceValue = get(record, source);
4545
const translate = useTranslate();
4646

4747
if (!sourceValue) {
@@ -86,12 +86,12 @@ export const FileField = <
8686
);
8787
}
8888

89-
const titleValue = get(record, title).toString() || title;
89+
const titleValue = get(record, title)?.toString() || title;
9090

9191
return (
9292
<Root className={className} {...sanitizeFieldRestProps(rest)}>
9393
<Link
94-
href={sourceValue}
94+
href={sourceValue?.toString()}
9595
title={titleValue}
9696
target={target}
9797
download={download}

packages/ra-ui-materialui/src/field/ImageField.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export const ImageField = <
1616
) => {
1717
const { className, emptyText, source, src, title, ...rest } = props;
1818
const record = useRecordContext(props);
19-
const sourceValue = get(record, source).toString();
19+
const sourceValue = get(record, source);
2020
const translate = useTranslate();
2121

2222
if (!sourceValue) {
@@ -62,14 +62,14 @@ export const ImageField = <
6262
);
6363
}
6464

65-
const titleValue = get(record, title).toString() || title;
65+
const titleValue = get(record, title)?.toString() || title;
6666

6767
return (
6868
<Root className={className} {...sanitizeFieldRestProps(rest)}>
6969
<img
7070
title={titleValue}
7171
alt={titleValue}
72-
src={sourceValue}
72+
src={sourceValue?.toString()}
7373
className={ImageFieldClasses.image}
7474
/>
7575
</Root>

0 commit comments

Comments
 (0)