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

<Autocomplete onCreate> briefly displays wrong option name #10043

Open
fzaninotto opened this issue Jul 23, 2024 · 0 comments
Open

<Autocomplete onCreate> briefly displays wrong option name #10043

fzaninotto opened this issue Jul 23, 2024 · 0 comments
Labels

Comments

@fzaninotto
Copy link
Member

What you were expecting:
When creating a new option on-the-fly using <Autocomplete onCreate>, the selected option should be the new option.

What happened instead:
The selected option switches to "Create XXX" before showing the correct "XXX"

Enregistrement.de.l.ecran.2024-07-23.a.11.55.22.mov

Steps to reproduce:

  1. Open the CRM demo and create a new contact (https://marmelab.com/react-admin-crm/#/contacts/create)
  2. Enter "Acme" in the company name
  3. Select "Create Acme" in the list of options

Related code:

const handleCreateCompany = async (name?: string) => {
if (!name) return;
try {
const newCompany = await create(
'companies',
{
data: {
name,
sales_id: identity?.id,
created_at: new Date().toISOString(),
},
},
{ returnPromise: true }
);
return newCompany;
} catch (error) {
notify('An error occurred while creating the company', {
type: 'error',
});
throw error;
}
};

Environment

  • React-admin version: v5
  • Last version that did not exhibit the issue (if applicable): n/a
  • React version: 18
  • Browser: Chrome
@fzaninotto fzaninotto added the bug label Jul 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant