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

Commit

Permalink
fix(md-select): Track disabled state
Browse files Browse the repository at this point in the history
Track the component disabled state in order to avoid a double
registration of click and key events on the md-select element in the
disabled $observe listener.

closes #1852
  • Loading branch information
troch authored and rschmukler committed Mar 11, 2015
1 parent 5fab400 commit dc93bff
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/components/select/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ function SelectDirective($mdSelect, $mdUtil, $mdTheming, $interpolate, $compile,

return function postLink(scope, element, attr, ctrls) {
var isOpen;
var isDisabled;

var mdSelectCtrl = ctrls[0];
var ngModel = ctrls[1];
Expand Down Expand Up @@ -158,6 +159,11 @@ function SelectDirective($mdSelect, $mdUtil, $mdTheming, $interpolate, $compile,
if (typeof disabled == "string") {
disabled = true;
}
// Prevent click event being registered twice
if (isDisabled !== undefined && isDisabled === disabled) {
return;
}
isDisabled = disabled;
if (disabled) {
element.attr('tabindex', -1);
element.off('click', openSelect);
Expand Down

0 comments on commit dc93bff

Please sign in to comment.