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

fix(select): disabled option no longer reacting to hover and closing on click #5619

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/select/select-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ md-select-menu.md-THEME_NAME-theme {
}
}
}
md-option:focus:not([selected]) {
md-option:focus:not([disabled]):not([selected]) {
background: '{{background-200}}';
}

Expand Down
14 changes: 8 additions & 6 deletions src/components/select/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -1199,14 +1199,16 @@ function SelectProvider($$interimElementProvider) {
if (ev && ( ev.type == 'mouseup') && (ev.currentTarget != dropDown[0])) return;
if ( mouseOnScrollbar() ) return;

if (!selectCtrl.isMultiple) {
opts.restoreFocus = true;
var option = $mdUtil.getClosest(ev.target, 'md-option');
if (option && option.hasAttribute && !option.hasAttribute('disabled')) {
if (!selectCtrl.isMultiple) {
opts.restoreFocus = true;

$mdUtil.nextTick(function() {
$mdSelect.hide(selectCtrl.ngModel.$viewValue);
}, true);
$mdUtil.nextTick(function () {
$mdSelect.hide(selectCtrl.ngModel.$viewValue);
}, true);
}
}

/**
* check if the mouseup event was on a scrollbar
*/
Expand Down
5 changes: 3 additions & 2 deletions src/components/select/select.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -843,7 +843,7 @@ describe('<md-select>', function() {
if (angular.isArray(options)) {
$rootScope.$$values = options;
var renderValueAs = compileOpts ? compileOpts.renderValueAs || 'value' : 'value';
optionsTpl = '<md-option ng-repeat="value in $$values" ng-value="value">{{' + renderValueAs + '}}</md-option>';
optionsTpl = '<md-option ng-repeat="value in $$values" ng-value="value"><div class="md-text">{{' + renderValueAs + '}}</div></md-option>';
} else if (angular.isString(options)) {
optionsTpl = options;
}
Expand Down Expand Up @@ -898,7 +898,7 @@ describe('<md-select>', function() {
function clickOption(index) {
inject(function($rootScope, $document) {
var openMenu = $document.find('md-select-menu');
var opt = $document.find('md-option')[index];
var opt = angular.element($document.find('md-option')[index]).find('div')[0];

if (!openMenu.length) throw Error('No select menu currently open');
if (!opt) throw Error('Could not find option at index: ' + index);
Expand All @@ -909,6 +909,7 @@ describe('<md-select>', function() {
});
angular.element(openMenu).triggerHandler({
type: 'mouseup',
target: target,
currentTarget: openMenu[0]
});
});
Expand Down