Skip to content

Commit 53536ad

Browse files
committed
Move click event listening to scrollView container instead of window
1 parent 90c2906 commit 53536ad

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

addon/components/scroll-view.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ function getScrolledToTopChanged(currentTop, lastTop, offset) {
4949

5050
function captureClick(e) {
5151
e.stopPropagation();
52-
window.removeEventListener('click', captureClick, true);
52+
e.target
53+
.closest('.ScrollView')
54+
.removeEventListener('click', captureClick, true);
5355
}
5456

5557
class ScrollView extends Component {
@@ -264,9 +266,10 @@ class ScrollView extends Component {
264266
// A touchend event can prevent a follow-on click event by calling preventDefault.
265267
// However, a mouseup event cannot do this so we need to capture the upcoming click instead.
266268
if (event instanceof MouseEvent) {
267-
window.addEventListener('click', captureClick, true);
269+
this.scrollViewElement.addEventListener('click', captureClick, true);
268270
} else {
269271
event.preventDefault();
272+
event.stopPropagation();
270273
}
271274
}
272275

0 commit comments

Comments
 (0)