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

Commit 8c79f32

Browse files
devversionThomasBurleson
authored andcommitted
fix(autocomplete): disable scroll events for autocomplete wrap layer
At the moment we set the z-index of the `autocomplete-wrap` to `51`, that's why it is usable while an open scrollmask So we only need to disable the scroll events to prevent scrolling when hovering over the `autocomplete-wrap` Fixes #6585. Fixes #5230. Fixes #5890. Closes #6589.
1 parent 4b29ddf commit 8c79f32

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

src/components/autocomplete/js/autocompleteController.js

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ function MdAutocompleteCtrl ($scope, $element, $mdUtil, $mdConstant, $mdTheming,
1919
selectedItemWatchers = [],
2020
hasFocus = false,
2121
lastCount = 0,
22-
fetchesInProgress = 0;
22+
fetchesInProgress = 0,
23+
enableWrapScroll = null;
2324

2425
//-- public variables with handlers
2526
defineProperty('hidden', handleHiddenChange, true);
@@ -247,15 +248,39 @@ function MdAutocompleteCtrl ($scope, $element, $mdUtil, $mdConstant, $mdTheming,
247248
if (elements) {
248249
$mdUtil.nextTick(function () {
249250
$mdUtil.disableScrollAround(elements.ul);
251+
enableWrapScroll = disableElementScrollEvents(angular.element(elements.wrap));
250252
}, false, $scope);
251253
}
252254
} else if (hidden && !oldHidden) {
253255
$mdUtil.nextTick(function () {
254256
$mdUtil.enableScrolling();
257+
258+
if (enableWrapScroll) {
259+
enableWrapScroll();
260+
enableWrapScroll = null;
261+
}
255262
}, false, $scope);
256263
}
257264
}
258265

266+
/**
267+
* Disables scrolling for a specific element
268+
*/
269+
function disableElementScrollEvents(element) {
270+
271+
function preventDefault(e) {
272+
e.preventDefault();
273+
}
274+
275+
element.on('wheel', preventDefault);
276+
element.on('touchmove', preventDefault);
277+
278+
return function() {
279+
element.off('wheel', preventDefault);
280+
element.off('touchmove', preventDefault);
281+
}
282+
}
283+
259284
/**
260285
* When the user mouses over the dropdown menu, ignore blur events.
261286
*/

0 commit comments

Comments
 (0)