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

Commit

Permalink
fix(select): Don't close on mouseup on scrollbar
Browse files Browse the repository at this point in the history
md-select should  not auto-close anymore when the scrollbar is used to scroll the options.

Fixes $4078. Closes #4229.
  • Loading branch information
FrankMeyer authored and ThomasBurleson committed Aug 19, 2015
1 parent fb85f67 commit 8fc273a
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/components/select/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -1107,6 +1107,7 @@ function SelectProvider($$interimElementProvider) {

function checkCloseMenu(ev) {
if (ev && ( ev.type == 'mouseup') && (ev.currentTarget != dropDown[0])) return;
if ( mouseOnScrollbar() ) return;

if (!selectCtrl.isMultiple) {
opts.restoreFocus = true;
Expand All @@ -1115,6 +1116,23 @@ function SelectProvider($$interimElementProvider) {
$mdSelect.hide(selectCtrl.ngModel.$viewValue);
}, true);
}

/**
* check if the mouseup event was on a scrollbar
*/
function mouseOnScrollbar() {
var clickOnScrollbar = false;
if(ev.currentTarget.children.length > 0) {
var child = ev.currentTarget.children[0];
var hasScrollbar = child.scrollHeight > child.clientHeight;
if (hasScrollbar && child.children.length > 0) {
var relPosX = ev.pageX - ev.currentTarget.getBoundingClientRect().left;
if(relPosX > child.children[0].offsetWidth)
clickOnScrollbar = true;
}
}
return clickOnScrollbar;
}
}
}

Expand Down

0 comments on commit 8fc273a

Please sign in to comment.