File tree 2 files changed +27
-2
lines changed
2 files changed +27
-2
lines changed Original file line number Diff line number Diff line change @@ -522,7 +522,7 @@ uis.controller('uiSelectCtrl',
522
522
ctrl . sizeSearchInput = function ( ) {
523
523
524
524
var input = ctrl . searchInput [ 0 ] ,
525
- container = ctrl . searchInput . parent ( ) . parent ( ) [ 0 ] ,
525
+ container = ctrl . $element [ 0 ] ,
526
526
calculateContainerWidth = function ( ) {
527
527
// Return the container width only if the search input is visible
528
528
return container . clientWidth * ! ! input . offsetParent ;
@@ -531,7 +531,7 @@ uis.controller('uiSelectCtrl',
531
531
if ( containerWidth === 0 ) {
532
532
return false ;
533
533
}
534
- var inputWidth = containerWidth - input . offsetLeft - 10 ;
534
+ var inputWidth = containerWidth - input . offsetLeft ;
535
535
if ( inputWidth < 50 ) inputWidth = containerWidth ;
536
536
ctrl . searchInput . css ( 'width' , inputWidth + 'px' ) ;
537
537
return true ;
Original file line number Diff line number Diff line change @@ -1925,6 +1925,31 @@ describe('ui-select tests', function() {
1925
1925
1926
1926
} ) ;
1927
1927
1928
+ it ( 'should update size of search input use container width' , function ( ) {
1929
+ scope . selection . selectedMultiple = [ scope . people [ 4 ] , scope . people [ 5 ] ] ; //Wladimir & Samantha
1930
+ var el = createUiSelectMultiple ( {
1931
+ appendToBody : true
1932
+ } ) ;
1933
+
1934
+ angular . element ( document . body ) . css ( "width" , "100%" ) ;
1935
+ angular . element ( document . body ) . css ( "height" , "100%" ) ;
1936
+ angular . element ( document . body ) . append ( el ) ;
1937
+
1938
+ spyOn ( el . scope ( ) . $select , 'sizeSearchInput' ) ;
1939
+
1940
+ var searchInput = el . find ( '.ui-select-search' ) ;
1941
+ el . find ( '.ui-select-match-item' ) . first ( ) . find ( '.ui-select-match-close' ) . click ( ) ;
1942
+
1943
+ expect ( el . scope ( ) . $select . sizeSearchInput ) . toHaveBeenCalled ( ) ;
1944
+
1945
+ $timeout . flush ( ) ;
1946
+
1947
+ var newWidth = searchInput [ 0 ] . clientWidth + searchInput [ 0 ] . offsetLeft ;
1948
+ var containerWidth = el [ 0 ] . clientWidth ;
1949
+ expect ( containerWidth - newWidth ) . toBeLessThan ( 10 ) ;
1950
+
1951
+ } ) ;
1952
+
1928
1953
it ( 'should move to last match when pressing BACKSPACE key from search' , function ( ) {
1929
1954
1930
1955
var el = createUiSelectMultiple ( ) ;
You can’t perform that action at this time.
0 commit comments