From 38fbdec5030d685e6cd5261fbf83c186b5d2f740 Mon Sep 17 00:00:00 2001 From: "Hubert Van de Walle (huvw)" Date: Fri, 13 Jan 2023 13:01:33 +0000 Subject: [PATCH] [FIX] web: restore drag&drop in Firefox Steps to reproduce ================== - Go to a kanban view - Drag a card by the title to another column -> The record is opened instead of being moved Cause of the issue ================== The `.o_kanban_record_headings` elements have a `overflow: hidden` rule There is a bug [0][1] in firefox from 17 years ago were the mouse{enter,leave} events are not fired in that case. Solution ======== The previous attempt [2] to fix the issue is not working (anymore ?) Thanks to a comment in the issue, we know that we can call `.preventDefault` on the mousedown event. [0]: https://bugzilla.mozilla.org/show_bug.cgi?id=339293 [1]: https://bugzilla.mozilla.org/show_bug.cgi?id=1352061 [2]: https://github.com/odoo/odoo/pull/104128 opw-3120973 opw-3121312 closes odoo/odoo#110282 X-original-commit: 713026806fa712afd85cb2530006f0f880dfa240 Signed-off-by: Julien Mougenot (jum) Signed-off-by: Hubert Van De Walle --- .../static/src/core/utils/draggable_hook_builder.js | 8 ++++++++ .../static/src/core/utils/draggable_hook_builder.scss | 11 +---------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/addons/web/static/src/core/utils/draggable_hook_builder.js b/addons/web/static/src/core/utils/draggable_hook_builder.js index 92f057b1a05..bc82bd1f42e 100644 --- a/addons/web/static/src/core/utils/draggable_hook_builder.js +++ b/addons/web/static/src/core/utils/draggable_hook_builder.js @@ -413,6 +413,14 @@ export function makeDraggableHook(hookParams = {}) { return; } + // In FireFox: elements with `overflow: hidden` will prevent mouseenter and mouseleave + // events from firing on elements underneath them. This is the case when dragging a card + // by the `.o_kanban_record_headings` element. In such cases, we can prevent the default + // action on the mousedown event to allow mouse events to fire properly. + // https://bugzilla.mozilla.org/show_bug.cgi?id=1352061 + // https://bugzilla.mozilla.org/show_bug.cgi?id=339293 + ev.preventDefault(); + ctx.currentContainer = ctx.ref.el; ctx.currentElement = ev.target.closest(ctx.elementSelector); diff --git a/addons/web/static/src/core/utils/draggable_hook_builder.scss b/addons/web/static/src/core/utils/draggable_hook_builder.scss index 657abf3138e..7c7a5e38fa2 100644 --- a/addons/web/static/src/core/utils/draggable_hook_builder.scss +++ b/addons/web/static/src/core/utils/draggable_hook_builder.scss @@ -1,14 +1,5 @@ .o_dragged { position: fixed !important; z-index: 1000 !important; - - // In FireFox: elements with `overflow: hidden` will prevent mouseenter and mouseleave - // events from firing on elements underneath them. This is the case when dragging a card - // by the `.o_kanban_record_headings` element. In such cases, the pointer events are - // disabled to allow mouse events to fire properly. - // https://bugzilla.mozilla.org/show_bug.cgi?id=1352061 - &, - * { - pointer-events: none; - } + pointer-events: none; }