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

3.0.0-beta.5: AutocompleteInput and allowEmpty issue #3920

Closed
MiMo42 opened this issue Nov 3, 2019 · 7 comments
Closed

3.0.0-beta.5: AutocompleteInput and allowEmpty issue #3920

MiMo42 opened this issue Nov 3, 2019 · 7 comments
Assignees
Labels

Comments

@MiMo42
Copy link
Contributor

MiMo42 commented Nov 3, 2019

What you were expecting:
AutocompleteInput shows suggestion for empty value to clear a current selection.

What happened instead:
The empty value suggestion item is shown if there is no matching value selected yet. Thats OK.
But:
If a matching value is selected, there is no empty suggestion item in list of suggestions.
So you can't change selection from previously selected value back to null (empty).

Steps to reproduce:
AutocompleteInput with allowEmpty set

Related code:
see useSuggestion hook: In getSuggestionsFactory the emptySuggestion is not added when limiting choices because of a currently selected item.
An emptySuggestion item will only be added to list of suggestions if no item has been selected yet.
This is why you cannot clear a current selection.

BTW: it would be more intuitive if the emptySelection would be inserted on top.
Currently the emptySelection item is appended and you have to scroll to reach it.

And: Clearing out the input field manually (backspace) and pressing Enter performs nothing although allowEmpty should cause a cleared input to select the matching emptySuggestion.

Environment

  • React-admin version: 3.0.0-beta.5
  • React version: 16.10
  • Browser: Chrome
@Kmaschta
Copy link
Contributor

Kmaschta commented Nov 4, 2019

Thank you for opening this issue. In order to confirm it, we'll have to reproduce it.
As explained in the bug report template, please fork the following CodeSandbox and repeat your issue on it:

https://codesandbox.io/s/github/marmelab/react-admin/tree/next/examples/simple

This is the simplest way to confirm a bug is related to the React Admin codebase.

@MiMo42
Copy link
Contributor Author

MiMo42 commented Nov 5, 2019

https://codesandbox.io/s/simple-rzpk0?fontsize=14
EditComment: I just added allowEmpty to ReferenceInput for post_id for demonstration purpose.
->No empty item is added to list of matches
I described the reason for that in my original post.

@Kmaschta
Copy link
Contributor

Kmaschta commented Nov 7, 2019

Confirmed, thanks for reporting!

@fzaninotto
Copy link
Member

Fixed by #3953

@anewcoder1992
Copy link

anewcoder1992 commented Nov 11, 2019

Fixed by #3953
@fzaninotto
this fix did not publish in beta.6?it seem did not on effect on beta.6

@anewcoder1992
Copy link

@fzaninotto this fix did not publish in beta.6?it seem did not on effect on beta.6

@fzaninotto
Copy link
Member

!yes it did, but you must set the allowEmpty prop on the ReferenceInput, not the AutocompleteInput.

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

4 participants