-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
Introduce ReferenceFieldBase #9698
Conversation
return id == null ? ( | ||
emptyText ? ( | ||
<Typography component="span" variant="body2"> | ||
{emptyText && translate(emptyText, { _: emptyText })} | ||
</Typography> | ||
) : null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it seems to me that this case is no longer handled
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Storybook disagrees with you. Having no id
will disable the query in useReferenceFieldController
so no referenceRecord
will be available at L146 in this file thus showing the empty message
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was an error in the useReferenceFieldController
though. Both the tests and the storybook show that all empty cases are handled
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Except in the previous code, the empty text was displayed in a Typography
. That's no longer the case.
options: UseReferenceFieldControllerOptions<ReferenceRecordType> | ||
): UseReferenceFieldControllerResult<ReferenceRecordType> => { | ||
const { source, link = 'edit', reference, queryOptions } = options; | ||
const record = useRecordContext<RecordType>(options); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
throw if reference is empty
Problem
While working on the alternative UI libraries demos, we had to re-implement all the reference fields and inputs logic.
Solution
Add core headless versions for these components
This PR introduces only the
ReferenceFieldBase
.Tasks