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 +29
-0
lines changed Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -454,9 +454,16 @@ uis.controller('uiSelectCtrl',
454
454
} ;
455
455
456
456
ctrl . clear = function ( $event ) {
457
+ var locals = { } ;
458
+ locals [ ctrl . parserResult . itemName ] = ctrl . selected ;
459
+
457
460
ctrl . select ( null ) ;
458
461
$event . stopPropagation ( ) ;
459
462
$timeout ( function ( ) {
463
+ ctrl . onRemoveCallback ( $scope , {
464
+ $item : ctrl . items [ ctrl . activeIndex ] ,
465
+ $model : ctrl . parserResult . modelMapper ( $scope , locals )
466
+ } ) ;
460
467
ctrl . focusser [ 0 ] . focus ( ) ;
461
468
} , 0 , false ) ;
462
469
} ;
Original file line number Diff line number Diff line change @@ -174,6 +174,7 @@ describe('ui-select tests', function () {
174
174
if ( attrs . backspaceReset !== undefined ) { attrsHtml += ' backspace-reset="' + attrs . backspaceReset + '"' ; }
175
175
if ( attrs . uiDisableChoice !== undefined ) { choicesAttrsHtml += ' ui-disable-choice="' + attrs . uiDisableChoice + '"' ; }
176
176
if ( attrs . removeSelected !== undefined ) { attrsHtml += ' remove-selected="' + attrs . removeSelected + '"' ; }
177
+ if ( attrs . onRemove !== undefined ) { attrsHtml += ' on-remove="' + attrs . onRemove + '"' ; }
177
178
}
178
179
179
180
return compileTemplate (
@@ -1369,6 +1370,27 @@ describe('ui-select tests', function () {
1369
1370
1370
1371
} ) ;
1371
1372
1373
+ it ( 'should invoke remove callback on remove for single select with allowClear enabled' , function ( ) {
1374
+ scope . selection . selected = scope . people [ 5 ] ;
1375
+
1376
+ scope . onRemoveFn = function ( $item , $model ) {
1377
+ scope . $item = $item ;
1378
+ scope . $model = $model ;
1379
+ } ;
1380
+
1381
+ var el = createUiSelect ( { onRemove : 'onRemoveFn($item, $model)' , allowClear : true } ) ;
1382
+
1383
+ expect ( scope . $item ) . toBeFalsy ( ) ;
1384
+ expect ( scope . $model ) . toBeFalsy ( ) ;
1385
+
1386
+ el . find ( '.glyphicon.glyphicon-remove' ) . click ( ) ;
1387
+ $timeout . flush ( ) ;
1388
+
1389
+ expect ( scope . $item ) . toEqual ( scope . people [ 5 ] ) ;
1390
+ expect ( scope . $model ) . toEqual ( scope . $item ) ;
1391
+
1392
+ } ) ;
1393
+
1372
1394
it ( 'should set $item & $model correctly when invoking callback on remove and no single prop. binding' , function ( ) {
1373
1395
1374
1396
scope . onRemoveFn = function ( $item , $model , $label ) {
You can’t perform that action at this time.
0 commit comments