Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

Commit

Permalink
fix(buttons): fix uibUncheckable using disable attrib for uibBtnRadio
Browse files Browse the repository at this point in the history
  • Loading branch information
navarroaxel committed May 8, 2017
1 parent a2dee1b commit fca5338
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/buttons/buttons.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ angular.module('ui.bootstrap.buttons', [])

if (attrs.uibUncheckable) {
scope.$watch(uncheckableExpr, function(uncheckable) {
attrs.$set('uncheckable', uncheckable ? '' : undefined);
attrs.$set('disabled', uncheckable ? 'disabled' : undefined);
});
}
}
Expand Down
7 changes: 5 additions & 2 deletions src/buttons/docs/demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,16 @@ <h4>Radio &amp; Uncheckable Radio</h4>
<label class="btn btn-primary" ng-model="radioModel" uib-btn-radio="'Right'">Right</label>
</div>
<div class="btn-group">
<label class="btn btn-success" ng-model="radioModel" uib-btn-radio="'Left'" uncheckable>Left</label>
<label class="btn btn-success" ng-model="radioModel" uib-btn-radio="'Middle'" uncheckable>Middle</label>
<label class="btn btn-success" ng-model="radioModel" uib-btn-radio="'Left'" uib-uncheckable="uncheckable">Left</label>
<label class="btn btn-success" ng-model="radioModel" uib-btn-radio="'Middle'">Middle</label>
<label class="btn btn-success" ng-model="radioModel" uib-btn-radio="'Right'" uib-uncheckable="uncheckable">Right</label>
</div>
<br/>
<div>
<button class="btn btn-default" ng-click="uncheckable = !uncheckable">
Toggle uncheckable
</button>
&nbsp;
uncheckable: {{uncheckable}}
</div>
</div>
10 changes: 5 additions & 5 deletions src/buttons/test/buttons.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -324,11 +324,11 @@ describe('buttons', function() {
});

describe('uibUncheckable', function() {
it('should set uncheckable', function() {
it('should set disabled', function() {
$scope.uncheckable = false;
var btns = compileButtons('<button ng-model="model" uib-btn-radio="1">click1</button><button ng-model="model" uib-btn-radio="2" uib-uncheckable="uncheckable">click2</button>', $scope);
expect(btns.eq(0).attr('uncheckable')).toBeUndefined();
expect(btns.eq(1).attr('uncheckable')).toBeUndefined();
expect(btns.eq(0).attr('disabled')).toBeUndefined();
expect(btns.eq(1).attr('disabled')).toBeUndefined();

expect($scope.model).toBeUndefined();

Expand All @@ -346,8 +346,8 @@ describe('buttons', function() {

$scope.uncheckable = true;
$scope.$digest();
expect(btns.eq(0).attr('uncheckable')).toBeUndefined();
expect(btns.eq(1).attr('uncheckable')).toBeDefined();
expect(btns.eq(0).attr('disabled')).toBeUndefined();
expect(btns.eq(1).attr('disabled')).toBeDefined();

btns.eq(0).click();
expect($scope.model).toEqual(1);
Expand Down

0 comments on commit fca5338

Please sign in to comment.