-
-
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
AutocompleteInput: TypeError: can't access property "record", getChoiceText(...).props is undefined #7286
Comments
In order to simplify the report, I remove the custom diff --git a/src/resources/users/components/UserReferenceInput.tsx b/src/resources/users/components/UserReferenceInput.tsx
index 53dd712..88e8f79 100644
--- a/src/resources/users/components/UserReferenceInput.tsx
+++ b/src/resources/users/components/UserReferenceInput.tsx
@@ -11,9 +11,6 @@ import {
import {
ReferenceInputProps,
} from 'ra-ui-materialui/lib/input/ReferenceInput';
-import {
- UserIdentityField,
-} from './UserIdentityField';
import {
UserRecord,
} from '../../../types';
@@ -31,7 +28,7 @@ const autocompleteDefaultOptions: Partial<AutocompleteInputProps> = {
return 'Inconnu.';
}
- return <UserIdentityField record={choice} />;
+ return choice.id.toString();
},
inputText: (choice: UserRecord) => choice?.name || '',
matchSuggestion: (_: string, choice: UserRecord) => Boolean(choice?.name), It "solves" the |
Removing the diff --git a/src/resources/users/components/UserReferenceInput.tsx b/src/resources/users/components/UserReferenceInput.tsx
index 53dd712..489ace2 100644
--- a/src/resources/users/components/UserReferenceInput.tsx
+++ b/src/resources/users/components/UserReferenceInput.tsx
@@ -33,7 +33,6 @@ const autocompleteDefaultOptions: Partial<AutocompleteInputProps> = {
return <UserIdentityField record={choice} />;
},
- inputText: (choice: UserRecord) => choice?.name || '',
matchSuggestion: (_: string, choice: UserRecord) => Boolean(choice?.name),
}; However, I still have the import React, {
VFC,
} from 'react';
import {
Typography,
makeStyles,
} from '@material-ui/core';
import {
FieldProps,
} from 'ra-ui-materialui';
import {
UserRecord,
} from '../../../types';
import {
UserAvatar,
} from './UserAvatar';
const useStyles = makeStyles((theme) => {
const avatarSize = theme.spacing(3);
return {
root: {
display: 'flex',
flexWrap: 'nowrap',
alignItems: 'center',
},
avatar: {
marginRight: theme.spacing(1),
marginTop: -theme.spacing(0.5),
marginBottom: -theme.spacing(0.5),
width: avatarSize,
height: avatarSize,
},
};
});
export const UserIdentityField: VFC<FieldProps<UserRecord>> = ({
record,
}) => {
const classes = useStyles();
return (
<div className={classes.root}>
<UserAvatar
user={record}
className={classes.avatar}
/>
<Typography variant="body2" component="span">
{record?.name || 'Anonyme'}
</Typography>
</div>
);
};
UserIdentityField.defaultProps = {
addLabel: true,
label: 'Identité',
};
export default null; |
Thanks for reporting this. Please provide a sample application showing the issue by forking the following CodeSandbox (https://codesandbox.io/s/github/marmelab/react-admin/tree/master/examples/simple). |
Hello @WiXSL, I'm working on the same project with @soullivaneuh |
@seojun-park, |
@WiXSL Maybe It'd be better link to see the code. please check https://codesandbox.io/s/bold-monad-yfsmcj?file=/src/posts/PostList.tsx As you can see the image below, The contents of And when I clicked a one content the page shows this : at line 35 on the code-sandbox link you would see :
|
Ok, let me check. Thanks |
I can reproduce this with other versions as well, Is not something of the latest version. |
Could you reproduce that then please? How version difference? our environment is
|
Yes, I'm looking into it |
I have a custom
UserReferenceInput
that usesReferenceInput
combined withAutocompleteInput
.Since last update, the choice list displays
[object Object]
instead of the expected name, and selecting one of the choices cause a crash with the following error:Stack trace
Related code:
Other information:
I bisected between the releases, and it looks the bug was introduced in
v3.19.8
.Environment
The text was updated successfully, but these errors were encountered: