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

Commit 57a4dbd

Browse files
committed
fix(buttons): fix uibUncheckable using disabled attrib for uibBtnRadio
1 parent a2dee1b commit 57a4dbd

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

src/buttons/buttons.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ angular.module('ui.bootstrap.buttons', [])
4444

4545
if (attrs.uibUncheckable) {
4646
scope.$watch(uncheckableExpr, function(uncheckable) {
47-
attrs.$set('uncheckable', uncheckable ? '' : undefined);
47+
attrs.$set('disabled', uncheckable ? 'disabled' : undefined);
4848
});
4949
}
5050
}

src/buttons/docs/demo.html

+5-2
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,16 @@ <h4>Radio &amp; Uncheckable Radio</h4>
2020
<label class="btn btn-primary" ng-model="radioModel" uib-btn-radio="'Right'">Right</label>
2121
</div>
2222
<div class="btn-group">
23-
<label class="btn btn-success" ng-model="radioModel" uib-btn-radio="'Left'" uncheckable>Left</label>
24-
<label class="btn btn-success" ng-model="radioModel" uib-btn-radio="'Middle'" uncheckable>Middle</label>
23+
<label class="btn btn-success" ng-model="radioModel" uib-btn-radio="'Left'" uib-uncheckable="uncheckable">Left</label>
24+
<label class="btn btn-success" ng-model="radioModel" uib-btn-radio="'Middle'">Middle</label>
2525
<label class="btn btn-success" ng-model="radioModel" uib-btn-radio="'Right'" uib-uncheckable="uncheckable">Right</label>
2626
</div>
27+
<br/>
2728
<div>
2829
<button class="btn btn-default" ng-click="uncheckable = !uncheckable">
2930
Toggle uncheckable
3031
</button>
32+
&nbsp;
33+
uncheckable: {{uncheckable}}
3134
</div>
3235
</div>

src/buttons/test/buttons.spec.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -324,11 +324,11 @@ describe('buttons', function() {
324324
});
325325

326326
describe('uibUncheckable', function() {
327-
it('should set uncheckable', function() {
327+
it('should set disabled', function() {
328328
$scope.uncheckable = false;
329329
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);
330-
expect(btns.eq(0).attr('uncheckable')).toBeUndefined();
331-
expect(btns.eq(1).attr('uncheckable')).toBeUndefined();
330+
expect(btns.eq(0).attr('disabled')).toBeUndefined();
331+
expect(btns.eq(1).attr('disabled')).toBeUndefined();
332332

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

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

347347
$scope.uncheckable = true;
348348
$scope.$digest();
349-
expect(btns.eq(0).attr('uncheckable')).toBeUndefined();
350-
expect(btns.eq(1).attr('uncheckable')).toBeDefined();
349+
expect(btns.eq(0).attr('disabled')).toBeUndefined();
350+
expect(btns.eq(1).attr('disabled')).toBeDefined();
351351

352352
btns.eq(0).click();
353353
expect($scope.model).toEqual(1);
@@ -356,10 +356,10 @@ describe('buttons', function() {
356356
expect($scope.model).toEqual(1);
357357

358358
btns.eq(1).click();
359-
expect($scope.model).toEqual(2);
359+
expect($scope.model).toEqual(1);
360360

361361
btns.eq(1).click();
362-
expect($scope.model).toBeNull();
362+
expect($scope.model).toEqual(1);
363363
});
364364
});
365365
});

0 commit comments

Comments
 (0)