This repository was archived by the owner on May 29, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed
Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -64,6 +64,10 @@ angular.module('ui.bootstrap.buttons', [])
6464
6565 //ui->model
6666 element . bind ( buttonsCtrl . toggleEvent , function ( ) {
67+ if ( 'disabled' in attrs ) {
68+ return ;
69+ }
70+
6771 scope . $apply ( function ( ) {
6872 ngModelCtrl . $setViewValue ( element . hasClass ( buttonsCtrl . activeClass ) ? getFalseValue ( ) : getTrueValue ( ) ) ;
6973 ngModelCtrl . $render ( ) ;
Original file line number Diff line number Diff line change @@ -81,6 +81,23 @@ describe('buttons', function () {
8181 expect ( $scope . model ) . toEqual ( 2 ) ;
8282 } ) ;
8383
84+ it ( 'should not toggle when disabled - issue 4013' , function ( ) {
85+ $scope . model = 1 ;
86+ $scope . falseVal = 0 ;
87+ var btn = compileButton ( '<button disabled ng-model="model" btn-checkbox btn-checkbox-true="falseVal">click</button>' , $scope ) ;
88+
89+ expect ( btn ) . not . toHaveClass ( 'active' ) ;
90+ expect ( $scope . model ) . toEqual ( 1 ) ;
91+
92+ btn . click ( ) ;
93+
94+ expect ( btn ) . not . toHaveClass ( 'active' ) ;
95+
96+ $scope . $digest ( ) ;
97+
98+ expect ( btn ) . not . toHaveClass ( 'active' ) ;
99+ } ) ;
100+
84101 describe ( 'setting buttonConfig' , function ( ) {
85102 var originalActiveClass , originalToggleEvent ;
86103
You can’t perform that action at this time.
0 commit comments