From d17c302c0a09eaa05fa63649650510a981704ff9 Mon Sep 17 00:00:00 2001 From: Joren Van Onder Date: Wed, 1 Mar 2017 19:27:27 -0800 Subject: [PATCH] [FIX] point_of_sale: undo mobile browser autoscroll in client list Mobile browsers attempt to scroll invisible input elements into view (eg. when they end up hidden behind the on-screen keyboard). The browser does not always correctly undo this. This is problematic because the main window in the client list is not actually scrollable for the user, so you ended up with part of the widget cut off. This implements a workaround that scrolls to top when input elements are blurred. Removing the blur handlers is not necessary because the input elements get removed. opw-706781 --- addons/point_of_sale/static/src/js/screens.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/addons/point_of_sale/static/src/js/screens.js b/addons/point_of_sale/static/src/js/screens.js index 6221180f271..013973cbbfc 100644 --- a/addons/point_of_sale/static/src/js/screens.js +++ b/addons/point_of_sale/static/src/js/screens.js @@ -1319,6 +1319,16 @@ var ClientListScreenWidget = ScreenWidget.extend({ contents.append($(QWeb.render('ClientDetailsEdit',{widget:this,partner:partner}))); this.toggle_save_button(); + // Browsers attempt to scroll invisible input elements + // into view (eg. when hidden behind keyboard). They don't + // seem to take into account that some elements are not + // scrollable. + contents.find('input').blur(function() { + setTimeout(function() { + self.$('.window').scrollTop(0); + }, 0); + }); + contents.find('.image-uploader').on('change',function(event){ self.load_image_file(event.target.files[0],function(res){ if (res) {