-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Conversation
return { | ||
restrict: 'A', | ||
link: function(scope,element,attrs){ | ||
scope.$watch(attrs.shouldFocus,function(newValue,oldValue){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is watching shouldFocus
, but there is no shouldFocus
attribute in the template - is this a mistake?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes! Sorry,my mistake...I mixed up the directive names. Now it's the way it should be
Is there any particular reason one cannot use a custom template and plug in your custom directive into that new template? |
I am not sure if that would help. In order to enable scrolling, the directive must be applied to the list element which is generated by the typeahead popup template. I will check it though. |
Yes it can be done with custom popup template, but it's still a bug in typeahead. Here is a plunker with the current version of typeahead (with the bug): Here is a plunker with this pull request where the scroll will work (the selected item will be visible). |
A simpler approach that would not require a new directive or adding a watch to each element in the dropdown would be to scroll the active item into view in the typeahead keydown handler here by adding the following code:
A plunk to demonstrate. |
oh. great! Thanks, will apply it as a change :) That's definitely a much easier solution. |
I updated to the latest version and this issue is still not fixed |
The fix is in |
okay thanks, will look it up. |
Downloaded and built the master repo and while the issue is fixed with keyboard-nav there is another bug left. Scenario.
Typeahead should focus the first suggestion and scroll to that suggestion but it doesn't. For the demo to reproduce: |
Enabled scrolling on key up/down event on typeahead (custom) popup template.
This is particularly useful if using custom template with fixed or max height. For popup exceeding results, scrolling with moose and keys can be used.
This is not my code (I did not write it) but I found it online (someone put it on plunker).
But it works and I think it would be of great use!