-
Notifications
You must be signed in to change notification settings - Fork 64
Add option that allows search to be triggered even if value is unchanged #43
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
base: master
Are you sure you want to change the base?
Conversation
|
Hey @matthew-sycle, I don't think I understand the use case. Lets say you have 10 options and 5 of them are 'Dave'. The user enters 'Da' in the box, _suggest is invoked with 'Da' and you return the 5 dave's as possible suggestions. At this point the user can either select on of the daves, add another digit 'Dav' to refine the search or remove a digit 'D'. So far so good. In what scenario is it possible for the user to enter the same input to the suggestion box and get different results? |
|
Say my input is "Bob". 10 options are displayed, and I pick the first one, which sets my ngModel, and hides the suggestions. I want a different "Bob", so I add or remove a character to trigger the suggest() again. Then I can pick a different "Bob". The problem is that the search string is unchanged after a debounce, even though the content had been modified. So I couldn't re-trigger |
|
To contrast from your example, I want to re-trigger the debounced |
I'm confused. Why do you need to trigger suggest to select a different "bob"? You can just select a different bob from the list. Note that if you have similar options in the list you are not expected to return different suggestions if I delete "b" and add it again. Select is triggered regardless of the value so if the user selected a bob in a different index you will get the select cb.
Unless the underlying data is changing when would you get different results here? |
|
The results could have changed (e.g. waiting for results in API to update), but I just want to be able to get the list of suggestions for "Bob" to display again, by quickly changing the string and changing it back again. Now that the suggestions are showing again, I can pick a different suggestion from the (same) results. |
If you load your suggestions from the server you need to return a promise from the suggest function. The box will appear only after the promise is resolves - this is already handled by the package. I still don't fully understand the use case here. I can't think of any situation where (given a stable set of results) a term can yield different suggestions. If the underlying data is changing while the box is displayed then it should be handled by notifying the promise (maybe) not by triggering changes in the model value. |
|
As I said, the search results may not have changed, I just want to be able to get those same suggestions (or maybe new ones) to display again, by re-triggering the As it is, it will normally re-trigger on a search string change, but it would NOT re-trigger for the same search string, which is what I need. |
|
@matthew-sycle - I recognize your point. I am experiencing exactly this issue. I think the desire we have can be captured in a more generic sense: What I want is to use MassAutoComplete in two different ways:
A non-unique value for suggestions is one of my use-cases: But as said, I have run into the same issue that an unchanged value does not re-show the suggestions. @hakib - do you recognize scenario 2 is a valid use-case? |
|
@udevnl Hey, if I understand your use case correctly it can be summed up to being able to show the suggest box when an input that already have text gets focus (e.g without typing)? |
|
@hakib Sorry for the later reply - Regarding what you said: More nuanced: |
|
@udevnl - not sure i understand. Lets take the first input in the example page. If i enter Can you give a simpler example of what you are trying to achieve? |
We have a use case where we can have many people with the same name, i.e. search string. This causes a problem in the part of the code which checks if the last search string is the same as the current search string, because it mean't we couldn't trigger the suggestions by entering the same search string.
This change adds an optional setting, which skips this "short-circuit" logic, and instead do the return in the
_suggestmethod, where we have access to check the$scope.selected_index. If the user has selected an index from the suggestions, we short-circuit the suggestion operation, immediately after resetting that$scope.selected_indexto0