From 6e3da7c07ded75fa1d83055bc04abf50a3e5eeb8 Mon Sep 17 00:00:00 2001 From: Krzysztof Kotlarek Date: Wed, 26 Jul 2023 11:56:54 +1000 Subject: [PATCH] FIX: distinguish between scroll and drag for sidebar (#22794) Change to drag move event handling. When position of mouse changed, we can assume it is not drag and drop, and we should keep default behaviour. Otherwise, we stop propagation of the event to handle drag and drop correctly. s --- .../discourse/app/lib/sidebar/section-link.js | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) 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); - event.stopPropagation(); - event.preventDefault(); + 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(); + } + + this.startMouseY = moveMouseY; if (!this.drag) { return;