Skip to content

A platform for community discussion. Free, open, simple.

FIX: distinguish between scroll and drag for sidebar (#22794)

Krzysztof Kotlarek6e3da7c07ded
diff --git a/app/assets/javascripts/discourse/app/lib/sidebar/section-link.js b/app/assets/javascripts/discourse/app/lib/sidebar/section-link.js
index c9ebe5218c8..e489222b5c1 100644
--- a/app/assets/javascripts/discourse/app/lib/sidebar/section-link.js
+++ b/app/assets/javascripts/discourse/app/lib/sidebar/section-link.js
@@ -82,10 +82,24 @@ export default class SectionLink {
@bind
dragMove(event) {
- this.startMouseY = this.#calcMouseY(event);
+ const moveMouseY = this.#calcMouseY(event);
+
+ if (this.willDrag && moveMouseY !== this.startMouseY && !this.drag) {
+ /**
+ * If mouse position is different, it means that it is a scroll and not drag and drop action.
+ * In that case, we want to do nothing and keep original behaviour.
+ */
+ this.willDrag = false;
+ return;
+ } else {
+ /**
+ * Otherwise, event propagation should be stopped as we have our own handler for drag and drop.
+ */
+ event.stopPropagation();
+ event.preventDefault();
+ }
- event.stopPropagation();
- event.preventDefault();
+ this.startMouseY = moveMouseY;
if (!this.drag) {
return;