Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

Commit

Permalink
fix(chips): Fix static chips remove padding.
Browse files Browse the repository at this point in the history
Static chips had some erroneous "remove" padding due to some recent
changes with the new `md-removable` feature.

Fix by updating the `isRemovable()` method to also check if the
component has an `ng-model` supplied and return false if not.

Also, minor change to demo to provide slightly better feedback to
the user.

Fixes #8887.

Closes #8888
  • Loading branch information
topherfangio authored and ThomasBurleson committed Jun 28, 2016
1 parent 7875bd6 commit 5c54632
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
8 changes: 8 additions & 0 deletions src/components/chips/chips.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1067,6 +1067,14 @@ describe('<md-chips>', function() {
expect(chipArray[1].innerHTML).toContain('2');
expect(chipArray[2].innerHTML).toContain('3');
});

it('does not allow removal of chips', function() {
scope.chipItem = 'Football';
var element = buildChips(STATIC_CHIPS_TEMPLATE);
var wrap = element.find('md-chips-wrap');

expect(wrap).not.toHaveClass('md-removable');
});
});

describe('<md-chip-remove>', function() {
Expand Down
3 changes: 1 addition & 2 deletions src/components/chips/demoBasicUsage/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ <h2 class="md-title">Display an ordered set of objects as chips (with custom tem
<br/>
<md-checkbox ng-model="ctrl.readonly">Readonly</md-checkbox>
<md-checkbox ng-model="ctrl.removable">
Removable
<span ng-if="ctrl.removable === undefined">(Currently is <code>undefined</code>)</span>
Removable (<code>{{ctrl.removable === undefined ? 'undefined' : ctrl.removable}}</code>)
</md-checkbox>
<p class="md-caption">
<b>Note</b>: When md-removable is undefined, readonly automatically sets md-removable to false.
Expand Down
5 changes: 5 additions & 0 deletions src/components/chips/js/chipsController.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,11 @@ MdChipsCtrl.prototype.isEditingChip = function() {


MdChipsCtrl.prototype.isRemovable = function() {
// Return false if we have static chips
if (!this.ngModelCtrl) {
return false;
}

return this.readonly ? this.removable :
angular.isDefined(this.removable) ? this.removable : true;
};
Expand Down

0 comments on commit 5c54632

Please sign in to comment.