@@ -1745,7 +1745,8 @@ describe('ui-select tests', function() {
1745
1745
1746
1746
function createUiSelectMultiple ( attrs ) {
1747
1747
var attrsHtml = '' ,
1748
- choicesAttrsHtml = '' ;
1748
+ choicesAttrsHtml = '' ,
1749
+ matchesAttrsHtml = '' ;
1749
1750
if ( attrs !== undefined ) {
1750
1751
if ( attrs . disabled !== undefined ) { attrsHtml += ' ng-disabled="' + attrs . disabled + '"' ; }
1751
1752
if ( attrs . required !== undefined ) { attrsHtml += ' ng-required="' + attrs . required + '"' ; }
@@ -1756,11 +1757,12 @@ describe('ui-select tests', function() {
1756
1757
if ( attrs . taggingLabel !== undefined ) { attrsHtml += ' tagging-label="' + attrs . taggingLabel + '"' ; }
1757
1758
if ( attrs . inputId !== undefined ) { attrsHtml += ' input-id="' + attrs . inputId + '"' ; }
1758
1759
if ( attrs . groupBy !== undefined ) { choicesAttrsHtml += ' group-by="' + attrs . groupBy + '"' ; }
1760
+ if ( attrs . lockChoice !== undefined ) { matchesAttrsHtml += ' ui-lock-choice="' + attrs . lockChoice + '"' ; }
1759
1761
}
1760
1762
1761
1763
return compileTemplate (
1762
1764
'<ui-select multiple ng-model="selection.selectedMultiple"' + attrsHtml + ' theme="bootstrap" style="width: 800px;"> \
1763
- <ui-select-match placeholder="Pick one...">{{$item.name}} <{{$item.email}}></ui-select-match> \
1765
+ <ui-select-match "' + matchesAttrsHtml + ' placeholder="Pick one...">{{$item.name}} <{{$item.email}}></ui-select-match> \
1764
1766
<ui-select-choices repeat="person in people | filter: $select.search"' + choicesAttrsHtml + '> \
1765
1767
<div ng-bind-html="person.name | highlight: $select.search"></div> \
1766
1768
<div ng-bind-html="person.email | highlight: $select.search"></div> \
@@ -1922,6 +1924,37 @@ describe('ui-select tests', function() {
1922
1924
1923
1925
} ) ;
1924
1926
1927
+ it ( 'should NOT remove highlighted match when pressing BACKSPACE key on a locked choice' , function ( ) {
1928
+
1929
+ scope . selection . selectedMultiple = [ scope . people [ 4 ] , scope . people [ 5 ] , scope . people [ 6 ] ] ; //Wladimir, Samantha & Nicole
1930
+ var el = createUiSelectMultiple ( { lockChoice : "$item.name == '" + scope . people [ 6 ] . name + "'" } ) ;
1931
+ var searchInput = el . find ( '.ui-select-search' ) ;
1932
+
1933
+ expect ( isDropdownOpened ( el ) ) . toEqual ( false ) ;
1934
+ triggerKeydown ( searchInput , Key . Left ) ;
1935
+ triggerKeydown ( searchInput , Key . Backspace ) ;
1936
+ expect ( el . scope ( ) . $select . selected ) . toEqual ( [ scope . people [ 4 ] , scope . people [ 5 ] , scope . people [ 6 ] ] ) ; //Wladimir, Samantha & Nicole
1937
+
1938
+ expect ( el . scope ( ) . $selectMultiple . activeMatchIndex ) . toBe ( scope . selection . selectedMultiple . length - 1 ) ;
1939
+
1940
+ } ) ;
1941
+
1942
+ it ( 'should NOT remove highlighted match when pressing DELETE key on a locked choice' , function ( ) {
1943
+
1944
+ scope . selection . selectedMultiple = [ scope . people [ 4 ] , scope . people [ 5 ] , scope . people [ 6 ] ] ; //Wladimir, Samantha & Nicole
1945
+ var el = createUiSelectMultiple ( { lockChoice : "$item.name == '" + scope . people [ 6 ] . name + "'" } ) ;
1946
+ var searchInput = el . find ( '.ui-select-search' ) ;
1947
+
1948
+ expect ( isDropdownOpened ( el ) ) . toEqual ( false ) ;
1949
+ triggerKeydown ( searchInput , Key . Left ) ;
1950
+ triggerKeydown ( searchInput , Key . Delete ) ;
1951
+ expect ( el . scope ( ) . $select . selected ) . toEqual ( [ scope . people [ 4 ] , scope . people [ 5 ] , scope . people [ 6 ] ] ) ; //Wladimir, Samantha & Nicole
1952
+
1953
+ expect ( el . scope ( ) . $selectMultiple . activeMatchIndex ) . toBe ( scope . selection . selectedMultiple . length - 1 ) ;
1954
+
1955
+ } ) ;
1956
+
1957
+
1925
1958
it ( 'should move to last match when pressing LEFT key from search' , function ( ) {
1926
1959
1927
1960
var el = createUiSelectMultiple ( ) ;
0 commit comments