From c3a7037afd61a37dc2699238c84e65ba6c0fea36 Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Mon, 23 Oct 2017 14:54:51 +0200 Subject: [FIX] web: restore scroll position when leaving form views For instance, open a list view with enough records so that there is a scrollbar, scroll, open a record of the bottom of the list and go back using the breadcrumbs: the scroll position should be restored. Before this rev., it wasn't the case: the scroll position was reset to the top of the list (i.e. to 0). This was due to the form renderer which manually triggered the event DOM_updated on the main bus to ensure that textareas were correctly autoresized. However, this wasn't done at the right place, and it impacted the way scroll positions of views were saved/restored. Indeed, this was only necessary when switching from readonly to edit mode, i.e. when the form view was actually already in the DOM, but not at each rendering as they may be performed outside the DOM (and in this case, the DOM_updated event is triggered by the view_manager when the view is really appended to the DOM). Note that this whole scroll mechanism relying on the DOM_updated event will probably change soon in master, with the refactoring of the upper part of the webclient. --- addons/web/static/src/js/views/basic/basic_controller.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'addons/web/static/src/js/views/basic/basic_controller.js') diff --git a/addons/web/static/src/js/views/basic/basic_controller.js b/addons/web/static/src/js/views/basic/basic_controller.js index dfbaeb3bd32..a109ea87d5a 100644 --- a/addons/web/static/src/js/views/basic/basic_controller.js +++ b/addons/web/static/src/js/views/basic/basic_controller.js @@ -447,7 +447,11 @@ var BasicController = AbstractController.extend(FieldManagerMixin, { */ _setMode: function (mode, recordID) { if ((recordID || this.handle) === this.handle) { - return this.update({mode: mode}, {reload: false}); + return this.update({mode: mode}, {reload: false}).then(function () { + // necessary to allow all sub widgets to use their dimensions in + // layout related activities, such as autoresize on fieldtexts + core.bus.trigger('DOM_updated'); + }); } return $.when(); }, -- cgit v1.2.3