This repository was archived by the owner on Oct 2, 2019. It is now read-only.
File tree 2 files changed +28
-3
lines changed
2 files changed +28
-3
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 @@ -2037,7 +2037,32 @@ describe('ui-select tests', function () {
2037
2037
2038
2038
} ) ;
2039
2039
2040
- it ( 'should move to last match when pressing BACKSPACE key from search' , function ( ) {
2040
+ it ( 'should update size of search input use container width' , function ( ) {
2041
+ scope . selection . selectedMultiple = [ scope . people [ 4 ] , scope . people [ 5 ] ] ; //Wladimir & Samantha
2042
+ var el = createUiSelectMultiple ( {
2043
+ appendToBody : true
2044
+ } ) ;
2045
+
2046
+ angular . element ( document . body ) . css ( "width" , "100%" ) ;
2047
+ angular . element ( document . body ) . css ( "height" , "100%" ) ;
2048
+ angular . element ( document . body ) . append ( el ) ;
2049
+
2050
+ spyOn ( el . scope ( ) . $select , 'sizeSearchInput' ) ;
2051
+
2052
+ var searchInput = el . find ( '.ui-select-search' ) ;
2053
+ el . find ( '.ui-select-match-item' ) . first ( ) . find ( '.ui-select-match-close' ) . click ( ) ;
2054
+
2055
+ expect ( el . scope ( ) . $select . sizeSearchInput ) . toHaveBeenCalled ( ) ;
2056
+
2057
+ $timeout . flush ( ) ;
2058
+
2059
+ var newWidth = searchInput [ 0 ] . clientWidth + searchInput [ 0 ] . offsetLeft ;
2060
+ var containerWidth = el [ 0 ] . clientWidth ;
2061
+ expect ( containerWidth - newWidth ) . toBeLessThan ( 10 ) ;
2062
+
2063
+ } ) ;
2064
+
2065
+ it ( 'should move to last match when pressing BACKSPACE key from search' , function ( ) {
2041
2066
2042
2067
var el = createUiSelectMultiple ( ) ;
2043
2068
var searchInput = el . find ( '.ui-select-search' ) ;
You can’t perform that action at this time.
0 commit comments