From d36d982dbf27a9d74e5364b722839e03a818b01a Mon Sep 17 00:00:00 2001 From: Mateusz Bieniek <38975612+mateuszbieniek@users.noreply.github.com> Date: Mon, 17 Sep 2018 09:41:45 +0200 Subject: [PATCH] =?UTF-8?q?EZP-28745:=20Disabled=20scrolling=20to=20top=20?= =?UTF-8?q?of=20the=20page=20on=20requesting=20more=20s=E2=80=A6=20(#979)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * EZP-28745: Disabled scrolling to top of the page on requesting more search results * Added missing readonly attribute descriptor for scrollToTopDefault --- Resources/public/js/apps/ez-platformuiapp.js | 13 +++++++++++++ .../js/views/services/ez-searchviewservice.js | 9 +++++++++ 2 files changed, 22 insertions(+) diff --git a/Resources/public/js/apps/ez-platformuiapp.js b/Resources/public/js/apps/ez-platformuiapp.js index ee4cbcf7e..6d6a57e5b 100644 --- a/Resources/public/js/apps/ez-platformuiapp.js +++ b/Resources/public/js/apps/ez-platformuiapp.js @@ -1206,6 +1206,19 @@ YUI.add('ez-platformuiapp', function (Y) { routingEnabled: { value: true, }, + + /** + * Boolean that determine if by default document should be scrolled to top on navigation + * + * @attribute scrollToTopDefault + * @default true + * @readOnly + * @type {Boolean} + */ + scrollToTopDefault: { + readOnly: true, + value: true, + }, } }); }); diff --git a/Resources/public/js/views/services/ez-searchviewservice.js b/Resources/public/js/views/services/ez-searchviewservice.js index f4a01161d..df94d2b52 100644 --- a/Resources/public/js/views/services/ez-searchviewservice.js +++ b/Resources/public/js/views/services/ez-searchviewservice.js @@ -22,9 +22,18 @@ YUI.add('ez-searchviewservice', function (Y) { Y.eZ.SearchViewService = Y.Base.create('searchViewService', Y.eZ.ViewService, [], { initializer: function () { + var app = this.get('app'); + this.on('*:searchRequest', function(e) { + // Setting scrollToTop to false, so requesting more results won't scroll back to top of the page. + app.set('scrollToTop', false); this._navigateToDoSearch(e); }); + + this.on('*:destroy', function() { + // Returning scrollToTop to previous value. + app.set('scrollToTop', app.get('scrollToTopDefault')); + }); }, /**