summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/views/search_panel.js
diff options
context:
space:
mode:
authorAaron Bohy <aab@odoo.com>2019-07-11 13:23:30 +0000
committerAaron Bohy <aab@odoo.com>2019-07-19 08:39:59 +0000
commit4bfb8b4dcad50a9b4b8e452c19ae3d0f339d1af7 (patch)
treea12f2c2cf51cf86d7e4b5f8d68cb826ee1ecc75a /addons/web/static/src/js/views/search_panel.js
parent87f1d1c8a9f3f82a536fc849390d511bf1f6a96f (diff)
[IMP] web: searchpanel: keep scroll position
... when switching between controllers
Diffstat (limited to 'addons/web/static/src/js/views/search_panel.js')
-rw-r--r--addons/web/static/src/js/views/search_panel.js13
1 files changed, 12 insertions, 1 deletions
diff --git a/addons/web/static/src/js/views/search_panel.js b/addons/web/static/src/js/views/search_panel.js
index 38872e8d381..f09ef071f79 100644
--- a/addons/web/static/src/js/views/search_panel.js
+++ b/addons/web/static/src/js/views/search_panel.js
@@ -95,6 +95,7 @@ var SearchPanel = Widget.extend({
});
this.initialState = params.state;
+ this.scrollTop = this.initialState && this.initialState.scrollTop || null;
this.defaultValues = params.defaultValues || {};
this.fields = params.fields;
this.model = params.model;
@@ -123,6 +124,14 @@ var SearchPanel = Widget.extend({
this._render();
return this._super.apply(this, arguments);
},
+ /**
+ * Called each time the searchPanel is attached into the DOM.
+ */
+ on_attach_callback: function () {
+ if (this.scrollTop !== null) {
+ this.el.scrollTop = this.scrollTop;
+ }
+ },
//--------------------------------------------------------------------------
// Public
@@ -175,6 +184,7 @@ var SearchPanel = Widget.extend({
return {
categories: this.categories,
filters: this.filters,
+ scrollTop: this.el ? this.el.scrollTop : null,
};
},
/**
@@ -192,8 +202,9 @@ var SearchPanel = Widget.extend({
* @param {Object} state.categories
*/
importState: function (state) {
- this.filters = state.filters || this.filters;
this.categories = state.categories || this.categories;
+ this.filters = state.filters || this.filters;
+ this.scrollTop = state.scrollTop;
this._render();
},
/**