diff options
| author | Aaron Bohy <aab@odoo.com> | 2019-07-11 13:23:30 +0000 |
|---|---|---|
| committer | Aaron Bohy <aab@odoo.com> | 2019-07-19 08:39:59 +0000 |
| commit | 4bfb8b4dcad50a9b4b8e452c19ae3d0f339d1af7 (patch) | |
| tree | a12f2c2cf51cf86d7e4b5f8d68cb826ee1ecc75a /addons/web/static/src | |
| parent | 87f1d1c8a9f3f82a536fc849390d511bf1f6a96f (diff) | |
[IMP] web: searchpanel: keep scroll position
... when switching between controllers
Diffstat (limited to 'addons/web/static/src')
| -rw-r--r-- | addons/web/static/src/js/views/abstract_controller.js | 3 | ||||
| -rw-r--r-- | addons/web/static/src/js/views/search_panel.js | 13 |
2 files changed, 15 insertions, 1 deletions
diff --git a/addons/web/static/src/js/views/abstract_controller.js b/addons/web/static/src/js/views/abstract_controller.js index 58a011599d1..53bcc0d5bad 100644 --- a/addons/web/static/src/js/views/abstract_controller.js +++ b/addons/web/static/src/js/views/abstract_controller.js @@ -113,6 +113,9 @@ var AbstractController = mvc.Controller.extend(ActionMixin, { if (this._controlPanel) { this._controlPanel.on_attach_callback(); } + if (this._searchPanel) { + this._searchPanel.on_attach_callback(); + } this.renderer.on_attach_callback(); }, /** 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(); }, /** |
