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] Remove startAfter feature #20551

Closed
2 tasks done
dohomi opened this issue Apr 14, 2020 · 14 comments · Fixed by #20729
Closed
2 tasks done

[Autocomplete] Remove startAfter feature #20551

dohomi opened this issue Apr 14, 2020 · 14 comments · Fixed by #20729
Labels
breaking change component: autocomplete This is the name of the generic UI component, not the React module! ready to take Help wanted. Guidance available. There is a high chance the change will be accepted

Comments

@dohomi
Copy link
Contributor

dohomi commented Apr 14, 2020

The Autocomplete startAfter custom filter works only with the option freeSolo otherwise the Popper is shown with noOptionText until the minimum number is hit.

  • The issue is present in the latest release.
  • I have searched the issues of this repository and believe that this is not a duplicate.

Current Behavior 😯

Showcase example with freeSolo
https://codesandbox.io/s/material-demo-e7oxj
Showcase example without freeSolo which seems buggy to me:
https://codesandbox.io/s/material-demo-t3my2

Expected Behavior 🤔

startAfter should work with or without freeSolo prop. It took me very long time to figure this out. Maybe otherwise it should be documented if this is the intended behaviour. Thanks!

Tech Version
Material-UI v4.9.10
React latest
Browser latest
TypeScript latest
@oliviertassinari
Copy link
Member

oliviertassinari commented Apr 14, 2020

@dohomi Interesting, this sounds like a good reason to remove the startAfter option and to leave it to userland (custom filter + custom open/close logic). The initial request come from #19591.

@oliviertassinari oliviertassinari added component: autocomplete This is the name of the generic UI component, not the React module! breaking change ready to take Help wanted. Guidance available. There is a high chance the change will be accepted labels Apr 14, 2020
@dohomi
Copy link
Contributor Author

dohomi commented Apr 15, 2020

@oliviertassinari custom filter + open prop on autocomplete sounds reasonable.

@oliviertassinari
Copy link
Member

oliviertassinari commented Apr 15, 2020

@dohomi Thanks for the confirmation :). It feels that the frequency of the use case vs the added logic in the core doesn't worth it. If you want to submit a pull request to revert #19591, we would be happy to review it.

@marcosvega91
Copy link
Contributor

@oliviertassinari maybe it can be a feature to keep and skip only in free solo mode, what do you think?

@oliviertassinari
Copy link
Member

I have never really understood the motivation for the prop in the first place. It feels like a logic you put in place to save requests to the backend API, not something you do to help users. I would be in favor of keeping the autocomplete simple.

@marcosvega91
Copy link
Contributor

If you want i can make a PR to remove the change

@oliviertassinari
Copy link
Member

@marcosvega91 No objection from my side 😬

@dohomi
Copy link
Contributor Author

dohomi commented Apr 22, 2020

@marcosvega91 the startAfter option works flawlessly on freeSolo. It would be a bummer if you revert the change without making it possible to get the same result in any other way.

@oliviertassinari
Copy link
Member

oliviertassinari commented Apr 22, 2020

@dohomi You can implement the same behavior by controlling the open state.

We have a usability issue when freeSolo={false} too. We don't give any feedback to the users that he needs to enter at least x chars. I think that in an acceptable version, we would display a "Need x more characters" message to guide the end-users. I think that it's better to leave it as a customization example.

@dohomi
Copy link
Contributor Author

dohomi commented Apr 22, 2020

@oliviertassinari ok yeah - maybe best would be a demo example and leave it by the developer

@marcosvega91
Copy link
Contributor

@dohomi You can implement the same behavior by controlling the open state.

We have a usability issue when freeSolo={false} too. We don't give any feedback to the users that he needs to enter at least x chars. I think that in an acceptable version, we would display a "Need x more characters" message to guide the end-users. I think that it's better to leave it as a customization example.

It sound's good but you need to change the behaviour of createFilterOptions because you need to access in some way to startAfter params inside useAutocomplete hook

@marcosvega91
Copy link
Contributor

@oliviertassinari Can I implement this feature?

My idea is to change the return value of both createFilterOptions and useAutocomplete.
I will add CreateFilterOptionsConfig object type in the return value, in this way in Autocomplete component I can access to startAfter property and check if inputValue length is enough.

What you think?

@oliviertassinari
Copy link
Member

@marcosvega91 Thanks for the proposal. I'm not sure to follow, which problem you aim to solve?

Regarding startAfter I think that we should move away from it, to focus on topics with a higher ROI. Regarding allowing custom labels in the popup, I believe we are already covered with the PaperComponent prop.

@marcosvega91
Copy link
Contributor

@oliviertassinari solve the problem with !freesolo. Instead of show a message of "No options" I want to show a different message

@oliviertassinari oliviertassinari changed the title [Autocomplete] startAfter custom filter only works with freeSolo prop is set to true [Autocomplete] Remove startAfter feature Apr 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change component: autocomplete This is the name of the generic UI component, not the React module! ready to take Help wanted. Guidance available. There is a high chance the change will be accepted
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants