From b214c62e266fced3702c3c41cf84ea4c5250526b Mon Sep 17 00:00:00 2001 From: "Hubert Van de Walle (huvw)" Date: Wed, 31 Aug 2022 09:20:02 +0000 Subject: [PATCH] [FIX] web: mobile: scroll in selection mode This is a port of https://github.com/odoo/enterprise/pull/30046 for wowl Steps to reproduce: On a mobile device: - Go to Inventory > Product Variants - Switch to the list view - Long press on a record -> We can't scroll to select records below the current screen closes odoo/odoo#105545 X-original-commit: cd874593b2390efba8e92228f85e9cf07c0e1a8c Related: odoo/enterprise#33861 Signed-off-by: Pierre Paridans (app) Signed-off-by: Hubert Van De Walle --- .../static/src/views/list/list_renderer.js | 37 +++++++++++++------ .../static/src/views/list/list_renderer.xml | 4 ++ 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/addons/web/static/src/views/list/list_renderer.js b/addons/web/static/src/views/list/list_renderer.js index b33506e0cb9..0fe4fa41f1b 100644 --- a/addons/web/static/src/views/list/list_renderer.js +++ b/addons/web/static/src/views/list/list_renderer.js @@ -1695,17 +1695,14 @@ export class ListRenderer extends Component { return; } if (this.props.list.selection.length) { - // in selection mode, only selection is allowed. - ev.preventDefault(); - this.toggleRecordSelection(record); - } else { - this.touchStartMs = Date.now(); - if (this.longTouchTimer === null) { - this.longTouchTimer = browser.setTimeout(() => { - this.toggleRecordSelection(record); - this.resetLongTouchTimer(); - }, this.constructor.LONG_TOUCH_THRESHOLD); - } + ev.stopPropagation(); // This is done in order to prevent the tooltip from showing up + } + this.touchStartMs = Date.now(); + if (this.longTouchTimer === null) { + this.longTouchTimer = browser.setTimeout(() => { + this.toggleRecordSelection(record); + this.resetLongTouchTimer(); + }, this.constructor.LONG_TOUCH_THRESHOLD); } } onRowTouchEnd(record) { @@ -1753,6 +1750,24 @@ export class ListRenderer extends Component { * @param {HTMLElement} [params.group] */ sortStop() {} + + ignoreEventInSelectionMode(ev) { + const { list } = this.props; + if (this.env.isSmall && list.selection && list.selection.length) { + // in selection mode, only selection is allowed. + ev.stopPropagation(); + ev.preventDefault(); + } + } + + onClickCapture(record, ev) { + const { list } = this.props; + if (this.env.isSmall && list.selection && list.selection.length) { + ev.stopPropagation(); + ev.preventDefault(); + this.toggleRecordSelection(record); + } + } } ListRenderer.template = "web.ListRenderer"; diff --git a/addons/web/static/src/views/list/list_renderer.xml b/addons/web/static/src/views/list/list_renderer.xml index 040284c7a77..a6a9edbbd66 100644 --- a/addons/web/static/src/views/list/list_renderer.xml +++ b/addons/web/static/src/views/list/list_renderer.xml @@ -209,6 +209,10 @@