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 filters by value only instead of value & text #103

Closed
heuristicAL opened this issue Dec 6, 2019 · 8 comments
Closed

Autocomplete filters by value only instead of value & text #103

heuristicAL opened this issue Dec 6, 2019 · 8 comments

Comments

@heuristicAL
Copy link

When I use an Autocomplete from this package, it seems to set the value of the autocomplete field as the input from the textbox. This is fine when I search for anything that is not contained in the 'value' field of my dataset but, as soon as I enter a value that is part of the dataset's value field, it automatically assigns that option as the only possible option. The normal ant autocomplete will keep showing me available options from the dataset's text field.

A possible fix could be to only set the Autocomplete's value attribute when an option is SELECTED and not when text is being typed into the input box.

As an example, if I have the following data:

[
{value: 0, text: 'Test'},
{value: 1, text: 'Text With 2'},
{value: 2, text: 'Text With 1'},
]

And I type in a '1' into the input box, the selected value will automatically become the second element {value: 1, text: 'Text With 2'}, even though I would expect it to also show me {value: 2, text: 'Text With 1'} as an option.

jannikbuschke added a commit that referenced this issue Dec 20, 2019
@jannikbuschke
Copy link
Owner

Should be fixed in v1.6.2

@thj-dk
Copy link

thj-dk commented Mar 10, 2020

@jannikbuschke while this fixes the search-issue, it introduces a new error when resetting the form using Formik's resetForm method. The field isn't cleared and still display the selected value.

I've tested this with the initial value set to both undefined, null and "". resetForm doesnt clears the field.

Any ideas?

@jannikbuschke
Copy link
Owner

jannikbuschke commented Mar 10, 2020

hi @thj-dk , thanks for bringing this up. Will need to investigate.

@jannikbuschke jannikbuschke reopened this Mar 10, 2020
@thj-dk
Copy link

thj-dk commented Apr 1, 2020

hi @thj-dk , thanks for bringing this up. Will need to investigate.

Did you get any chance of looking into this yet?

jannikbuschke added a commit that referenced this issue Apr 1, 2020
@jannikbuschke
Copy link
Owner

Should be fixed in v2.0.1. Feel free to reopen if otherwise.

@thj-dk
Copy link

thj-dk commented Apr 2, 2020

Sounds good!
We haven't upgraded antd to v4 yet. What's the easiest way of getting that commit applied for v1?

@jannikbuschke
Copy link
Owner

The fix to the original issue and the new fix conflict unfortunately and seem to not work with ant d 3. I just tried to apply the changes to v1.9 but I get errors.
For me it is to much of an effort to make it really work for v1.x / antd 3

You can check if

  • Rolling back to formik-antd v1.6.1 or earlier is possible for you
  • Extract the autocomplete field and try a custom solution that works for you
  • Try to update to ant d 4 soon

@thj-dk
Copy link

thj-dk commented Apr 7, 2020

No worries. We'll prioritize upgrading to antd4 asap. Thank you.

jannikbuschke added a commit that referenced this issue May 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants