-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Proposition for typeahead : Open suggestion view on focus #764
Comments
So, I think that there was a brief discussion about something similar. The problem is that semantic of such thing gets very tricky very fast. One of the main design assumptions of the current typeahead directive is that it should work seamlessly with promises (with any typeahead suggestions to be retrieved asynchronously, usually from a server side). Now if we take this into account the question is - what should be shown in the opened popup? If the input is empty what should we send as a query to the server? I guess this is not super-common use case for the typeahead directive and as such I would prefer no to add more code / complexity to the directive itself. What I would rather look at is a way of making sure that such functionality can be pluggable. I'm starting to think about refactoring the current directive to use an internal controller so people can plug into the directive. If I'm not mistaken it should be possible even today to write a simple directive that would listen to the focus event and write a value to the @jdecool Could you give a separate directive a try? I would be keen to refactor the existing typeahead directive so custom / additional behavior is easy to plug. |
I'd like to second the suggestion to show the popup on focus if With your $viewValue idea to show the popup on focus from a directive, what value should be written? Just an empty string? (I'm a little new to all of this.) (Thank you for your efforts on this and other parts of ui-bootstrap!) |
It's a very interresting idea to allow user to plug an internal controller into the directive to extends functionnalities ! I also agree with @sanfords that displaying suggestion view on focus, is similar to have a typeahead-min-length=0. Right now, I'm going to try to add a directive to catch the "focus" event. |
jdecool, thanks for working on that directive! I put together two sample apps on another platform to see how a typeahead would "feel" with showing popups on focus. One popped up on focus, and the other popped up on "keyboard down-arrow". I preferred "down-arrow". I guess this could be easily done with the same directive, right? The select2 control also uses down-arrow to show choices. Has down-arrow become a standard for showing options in typeahead-like controls? At some point this may be what the users expect. |
I have tried to use select2 in my app. The disavantage of the library is that user have to do an action to view type of result. So I try to make an UI which can be use only with keyboard et the most intuitive as possible. Basic users don't know that they have to press the "down-arrow" to show suggestions. By opening the list on focus, user is guided. |
So I think there's a case to be made for both. First is showing the popup on focus: This would be good for, say, a country popup where a one-time user will need to see the choices immediately. Second is the user who doesn't need to see all the options immediately because they have experience with the form, or the typeahead field is one of 10 fields on the page and don't want the popup flashing in front of them as they tab around. |
hello, has there been any more thought/work towards opening the pop-up when minlength=0 and focus event is fired? I really need this. thanks |
To open suggestions on keydown 40 (version 0.6) You can try this workaround : first instruction in link function replaced by And in the keydown event, add this test before the first one (become if / else if) : In unshift function, first test become : It wont break anything and will open the suggestion popup when you hit down arrow on an empty input |
cindoum, wonderful. This should be in 0.7. |
Glad it can help you. I am actually working on adding a few behaviors and fixing some glitchs. If any of them could help people, i might start a branch. New feature :
Fix done :
|
To open it on focus, with the fixed described in my previous post, it should not be harder than adding a directive on the input (like typeahead-open-on-focus) and in the link function bind on element focus and then set modelCtrl.$setViewValue(''); (need require: NgModel). This directive is describe somewhere else in an issue. (not tested) |
When investigating typeaheads a few months ago I realized that everybody has a different opinion what a typeahead should be. :-) So here's what I personally need from a typeahead:
I believe 1, 3, 4 are in your list. |
Typeahead seam to go in a way : advanced input, for me it is more an advanced select... Most of what your asking is already possbile.
The 3 is not a behavior i will be working on as it seem ok to me. If editable = false, it return the match or null, that is what i expect and if editable = true, it return the match object or the string typed in the input if cannot fit it to matches. |
This is great news. There are so many typeheads out there I just wanted to enumerate what I'd like. I think they've all blended together in my mind. #6 is actually important. Users with large screens can easily see > 30 items in the dropdown. And they'll often want to scroll through the choices before typing. It's especially important combined with #1 and empty input, I think. |
I have it working but this is not a clean way to do it, but i need the typeahead working as we expected for yesterday so ill keep this. Here is what i've done (if it can help people while a cleaner way is found):
As i said, this is more of a hack than a new feature. I didnt want to make the toggle button part of the typeahead, so everything is left outside. EDIT: Sorry for indentation, cannot find proper tag to show code :/ |
If you dont want to use a limitTo filter, you could also (or both) set a maxHeight with a overflow-y: auto to wrap the suggestion popup with a scroll bar... I am not sure to understand how you would like it to be? Showing 30+ suggestions, if no maxHeight or any kind of pagination / filtering will alway go down to the page bottom... |
would be great to have; it looks like this is requested pretty often, and I'm trying to hack my way through it right now. Do you have this up anywhere? |
Thank you for your efforts with this. I think these are great additions to typeahead. |
I think so also minLength=0 has a lot of added value |
Regarding large lists, I don't think it's too much to present hundreds of items to users. It seems kind of the norm, actually. Having hundreds of bound choices though will slow down rendering if there are just a few typeaheads on-screen. Is there a way to either not-bind (or cleverly bind) the list choices or use something like angular-virtual-scroll? |
I also agree this would be very beneficial functionality. I have several scenarios where the list of options gets filtered by other inputs, and so it would be helpful to set that minLength property to 0, and allow the user to view the entire list when they get to the input opposed to being required to guess at which of the few values are still applicable. It sounded like there was a concern with sending off a query of nothing, but I would imagine you'd want the server method call to be limited in how much data it will return in general. |
+1 |
useful when the options were not huge, so show options when input was focus can save user memory and user can type adhoc strings too. |
+1 is any plans to include the feature? :) |
I just added this in the link function and worked just fine: element.bind('focus', function(ev) { modelCtrl.$setViewValue(' '); }); |
I would like typeahead to show all possible completions on click. This is similar to ui-select2. I have some code that accomplishes this, but it needs to be cleaned up. |
+1 |
No more +1 comments please That way we can be notified about comments that actually need attention instead of being flooded with +1's In the meanwhile -- All PR's covering this feature are more than welcome |
Can you update Angular-UI doc to reflex the fact that typeahead-min-data cannot be 0 and should be 1 or more, please? |
@Enykey please feel free to fork the repo and submit a PR. |
This seems to be one of the most sought after feature yet there is no one who's working on it. WHY?! Moreover, yohairosen(http://stackoverflow.com/users/1270769/yohairosen) has already developed a workaround - http://stackoverflow.com/a/27331340/3955513 |
@shyamal890 please exercise patience/professionalism - maintaining a large open source project is difficult, and we have many issues that we have to manage with limited resources. Showing impatience will not get us to consider this faster, and only adds noise since instead of working through the backlog of issues, we are being distracted improperly - we are doing the best we can to get through our backlog of issues and systematically address them, and adding noise will only slow down the project more. |
Thank you @chenyuzhcy for answering a 2 year awaited question with < 10 lines of code! |
+1 |
I created a directive that embeds the Typeahead directive and mimics the functionality of a combobox/select:
Here is my plunk: http://plnkr.co/edit/zWN950IxOndlYQHBXdY9?p=preview |
Its Easy to add only $scope.selected = ' '; in your controller.. i have checked with ui-bootstrap-tpls-0.10.0.js and its working fine. |
@santosh-k1, I think you may have gotten that version number wrong. We're currently at version 1.1.1. |
+1 |
@lin-credible, please do not just add a |
@santosh-k1 work for me ! Thanks! |
Any update for this feature? Need it when we need to always show a default option on focus before trigger any search...... |
@copiali below code will help you to resolve the issue.. it has open the value on text box focus:
Working Demo Link : Demo http://plnkr.co/edit/bZMEOx0Qwo6VzW7oSuEE?p=preview |
+1 |
It could be interresting to automatically open the suggestion view when the input field has focus.
It will allow user to see choices it can make when a filter is used and the list is not editable.
What do you think about ?
The text was updated successfully, but these errors were encountered: