From a3477a8c088f706e0eba6563323359cff703ed59 Mon Sep 17 00:00:00 2001 From: Elad Bezalel Date: Sun, 8 Nov 2015 20:41:42 +0200 Subject: [PATCH] fix(select): disabled option no longer reacting to hover and closing on click Added a not disabled check before closing menu, Now when clicking the menu anywhere but a valid option the menu closing will be prevented fixes #4967 --- src/components/select/select-theme.scss | 2 +- src/components/select/select.js | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/components/select/select-theme.scss b/src/components/select/select-theme.scss index e45fbe236a6..136a937e8d0 100644 --- a/src/components/select/select-theme.scss +++ b/src/components/select/select-theme.scss @@ -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}}'; } diff --git a/src/components/select/select.js b/src/components/select/select.js index 76f8f183110..9d4deb6426c 100755 --- a/src/components/select/select.js +++ b/src/components/select/select.js @@ -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 */