This repository was archived by the owner on Oct 2, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +37
-1
lines changed Expand file tree Collapse file tree 2 files changed +37
-1
lines changed Original file line number Diff line number Diff line change 305
305
} ;
306
306
307
307
ctrl . isActive = function ( itemScope ) {
308
- return ctrl . open && ctrl . items . indexOf ( itemScope [ ctrl . itemProperty ] ) === ctrl . activeIndex ;
308
+ var isActive = ctrl . open && ctrl . items . indexOf ( itemScope [ ctrl . itemProperty ] ) === ctrl . activeIndex ;
309
+
310
+ if ( isActive && ! angular . isUndefined ( ctrl . onHighlightCallback ) ) {
311
+ itemScope . $eval ( ctrl . onHighlightCallback ) ;
312
+ }
313
+
314
+ return isActive ;
309
315
} ;
310
316
311
317
ctrl . isDisabled = function ( itemScope ) {
888
894
$select . parseRepeatAttr ( attrs . repeat , groupByExp ) ; //Result ready at $select.parserResult
889
895
890
896
$select . disableChoiceExpression = attrs . uiDisableChoice ;
897
+ $select . onHighlightCallback = attrs . onHighlight ;
891
898
892
899
if ( groupByExp ) {
893
900
var groups = element . querySelectorAll ( '.ui-select-choices-group' ) ;
Original file line number Diff line number Diff line change @@ -727,6 +727,35 @@ describe('ui-select tests', function() {
727
727
728
728
} ) ;
729
729
730
+ it ( 'should invoke hover callback' , function ( ) {
731
+
732
+ var highlighted ;
733
+ scope . onHighlightFn = function ( $item ) {
734
+ highlighted = $item ;
735
+ } ;
736
+
737
+ var el = compileTemplate (
738
+ '<ui-select on-select="onSelectFn($item, $model)" ng-model="selection.selected"> \
739
+ <ui-select-match placeholder="Pick one...">{{$select.selected.name}}</ui-select-match> \
740
+ <ui-select-choices on-highlight="onHighlightFn(person)" repeat="person.name as person in people | filter: $select.search"> \
741
+ <div ng-bind-html="person.name | highlight: $select.search"></div> \
742
+ <div ng-bind-html="person.email | highlight: $select.search"></div> \
743
+ </ui-select-choices> \
744
+ </ui-select>'
745
+ ) ;
746
+
747
+ expect ( highlighted ) . toBeFalsy ( ) ;
748
+
749
+ if ( ! isDropdownOpened ( el ) ) {
750
+ openDropdown ( el ) ;
751
+ }
752
+
753
+ $ ( el ) . find ( '.ui-select-choices-row div:contains("Samantha")' ) . trigger ( 'mouseover' ) ;
754
+ scope . $digest ( ) ;
755
+
756
+ expect ( highlighted ) . toBe ( scope . people [ 5 ] ) ;
757
+ } )
758
+
730
759
it ( 'should set $item & $model correctly when invoking callback on select and no single prop. binding' , function ( ) {
731
760
732
761
scope . onSelectFn = function ( $item , $model , $label ) {
You can’t perform that action at this time.
0 commit comments