diff options
| author | Aaron Bohy <aab@odoo.com> | 2018-03-08 14:57:43 +0100 |
|---|---|---|
| committer | Aaron Bohy <aab@odoo.com> | 2018-03-10 09:01:46 +0100 |
| commit | 4e204ed2233ccd36b2eb7d3e56bfa741b9cb3e14 (patch) | |
| tree | a4c5dc6c77459b1590c601d4b21ca203ccc005f5 /addons/web/static/tests | |
| parent | 1a99d22f19949cf8eb689a6e2d6eda859c963cf9 (diff) | |
[IMP] web: restore scroll position
This rev. improves the way the scroll position is restored when
coming back to a view (e.g. open a kanban view, scroll, click on a
record to open it in a form view, go back to kanban using the
breadcrumbs):
- generalize the scroll position handling from web_enterprise to
web to make it available in the community webclient as well
- also restore left scroll position, not only top (especially
useful for grouped Kanban views with a lot of columns)
- handle the case where the scrolling area is a sub element of
the view (e.g. the grouped Kanban view in mobile).
Task 34037
Co-authored-by: Mohammed Shekha <msh@openerp.com>
Co-authored-by: Ankit Sathvara <asa@odoo.com>
Diffstat (limited to 'addons/web/static/tests')
| -rw-r--r-- | addons/web/static/tests/chrome/action_manager_tests.js | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/addons/web/static/tests/chrome/action_manager_tests.js b/addons/web/static/tests/chrome/action_manager_tests.js index 9f7bacc1689..4d46b9167d1 100644 --- a/addons/web/static/tests/chrome/action_manager_tests.js +++ b/addons/web/static/tests/chrome/action_manager_tests.js @@ -350,6 +350,52 @@ QUnit.module('ActionManager', { actionManager.destroy(); }); + QUnit.test('stores and restores scroll position', function (assert) { + assert.expect(7); + + var left; + var top; + var actionManager = createActionManager({ + actions: this.actions, + archs: this.archs, + data: this.data, + intercepts: { + getScrollPosition: function (ev) { + assert.step('getScrollPosition'); + ev.data.callback({left: left, top: top}); + }, + scrollTo: function (ev) { + assert.step('scrollTo left ' + ev.data.left + ', top ' + ev.data.top); + }, + }, + }); + + // execute a first action and simulate a scroll + assert.step('execute action 3'); + actionManager.doAction(3); + left = 50; + top = 100; + + // execute a second action (in which we don't scroll) + assert.step('execute action 4'); + actionManager.doAction(4); + + // go back using the breadcrumbs + assert.step('go back to action 3'); + $('.o_control_panel .breadcrumb a').click(); + + assert.verifySteps([ + 'execute action 3', + 'execute action 4', + 'getScrollPosition', // of action 3, before leaving it + 'go back to action 3', + 'getScrollPosition', // of action 4, before leaving it + 'scrollTo left 50, top 100', // restore scroll position of action 3 + ]); + + actionManager.destroy(); + }); + QUnit.module('Push State'); QUnit.test('properly push state', function (assert) { |
