[FIX] web: drag and drop: allow pointer down blur

If one edits an input value in a dialog and click on the dialog header,
the blur event is prevented because the dialog is draggable and the
pointer down native behaviour is prevented by the draggable hook builder.
This can cause data losses or the dialog content to not be render correctly.
For instance, this happens with the debug input of the domain selector
dialog.
We fix that by triggering the blur event programatically.

closes odoo/odoo#140436

Signed-off-by: Julien Mougenot (jum) <jum@odoo.com>
This commit is contained in:
Mathieu Duckerts-Antoine
2023-10-31 10:34:01 +00:00
parent 090b721f7e
commit ef97eaf987
@@ -517,7 +517,7 @@ export function makeDraggableHook(hookParams) {
return (
!ctx.tolerance ||
Math.hypot(pointer.x - initialPosition.x, pointer.y - initialPosition.y) >=
ctx.tolerance
ctx.tolerance
);
};
@@ -693,6 +693,9 @@ export function makeDraggableHook(hookParams) {
// https://bugzilla.mozilla.org/show_bug.cgi?id=1352061
// https://bugzilla.mozilla.org/show_bug.cgi?id=339293
safePrevent(ev);
if (document.activeElement && !document.activeElement.contains(ev.target)) {
document.activeElement.blur();
}
const { currentTarget, pointerId, target } = ev;
ctx.current.initialPosition = { ...ctx.pointer };
@@ -989,7 +992,7 @@ export function makeDraggableHook(hookParams) {
// be fired. Note that we DO NOT want to prevent touchstart
// events since they're responsible of the native swipe
// scrolling.
addListener(el, "touchstart", () => {}, {
addListener(el, "touchstart", () => { }, {
passive: false,
noAddedStyle: true,
});