You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
I want to display empty text in case where reference is set but the referenced entity is missing. This is easily a case in systems where soft deleting is allowed.
Describe the solution you'd like
For now I am using the same emptyText as is used in the same case where the reference is not set. This works for me, but maybe best is to have a separate prop. Here is the patch:
diff --git a/node_modules/ra-ui-materialui/esm/field/ReferenceField.js b/node_modules/ra-ui-materialui/esm/field/ReferenceField.js
index 3dc814e..f44ccae 100644
--- a/node_modules/ra-ui-materialui/esm/field/ReferenceField.js+++ b/node_modules/ra-ui-materialui/esm/field/ReferenceField.js@@ -85,7 +85,7 @@ var ReferenceField = function (props) {
if (!isReferenceDeclared) {
throw new Error("You must declare a <Resource name=\"" + props.reference + "\"> in order to use a <ReferenceField reference=\"" + props.reference + "\">");
}
- return get(record, source) == null ? (emptyText ? (React.createElement(Typography, { component: "span", variant: "body2" }, emptyText)) : null) : (React.createElement(NonEmptyReferenceField, __assign({}, rest, { record: record, source: source })));+ return get(record, source) == null ? (emptyText ? (React.createElement(Typography, { component: "span", variant: "body2" }, emptyText)) : null) : (React.createElement(NonEmptyReferenceField, __assign({}, rest, { emptyText, record: record, source: source })));
};
ReferenceField.propTypes = {
addLabel: PropTypes.bool,
@@ -157,7 +157,7 @@ export var ReferenceFieldView = function (props) {
return React.createElement(LinearProgress, null);
}
if (!referenceRecord) {
- return null;+ return props.emptyText || null;
}
if (resourceLinkPath) {
return (React.createElement(RecordContextProvider, { value: referenceRecord },
Describe alternatives you've considered
N\A
Additional context
N\A
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
I want to display empty text in case where reference is set but the referenced entity is missing. This is easily a case in systems where soft deleting is allowed.
Describe the solution you'd like
For now I am using the same
emptyText
as is used in the same case where the reference is not set. This works for me, but maybe best is to have a separate prop. Here is the patch:Describe alternatives you've considered
N\A
Additional context
N\A
The text was updated successfully, but these errors were encountered: