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 +28
-3
lines changed Expand file tree Collapse file tree 2 files changed +28
-3
lines changed Original file line number Diff line number Diff line change @@ -522,7 +522,7 @@ uis.controller('uiSelectCtrl',
522522 ctrl . sizeSearchInput = function ( ) {
523523
524524 var input = ctrl . searchInput [ 0 ] ,
525- container = ctrl . searchInput . parent ( ) . parent ( ) [ 0 ] ,
525+ container = ctrl . $element [ 0 ] ,
526526 calculateContainerWidth = function ( ) {
527527 // Return the container width only if the search input is visible
528528 return container . clientWidth * ! ! input . offsetParent ;
@@ -531,7 +531,7 @@ uis.controller('uiSelectCtrl',
531531 if ( containerWidth === 0 ) {
532532 return false ;
533533 }
534- var inputWidth = containerWidth - input . offsetLeft - 10 ;
534+ var inputWidth = containerWidth - input . offsetLeft ;
535535 if ( inputWidth < 50 ) inputWidth = containerWidth ;
536536 ctrl . searchInput . css ( 'width' , inputWidth + 'px' ) ;
537537 return true ;
Original file line number Diff line number Diff line change @@ -2037,7 +2037,32 @@ describe('ui-select tests', function () {
20372037
20382038 } ) ;
20392039
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 ( ) {
20412066
20422067 var el = createUiSelectMultiple ( ) ;
20432068 var searchInput = el . find ( '.ui-select-search' ) ;
You can’t perform that action at this time.
0 commit comments