Skip to content

Commit

Permalink
feat(mobileWizard): keep past scroll position
Browse files Browse the repository at this point in the history
In I02365ecef859fb6f199d14a12a49937d5a30b8e7
(#9230) we made the scroll position of a menu
always return to the top. This was to avoid a bug where a submenu would
keep its scroll, starting partway down and obscuring the top items.

In the review, it was mentioned that it would be even better to keep the
scroll position of the menu when returning to it. For simplicity I've
opted to only keep the position of menus up of you (so exiting a submenu
then reopening it will keep the position of the top menu, but not the
submenu), I make no comment on which way would be better as a user

Signed-off-by: Skyler Grey <[email protected]>
Change-Id: If82ff0b586a65349452fe8ebfb7fa046e4f874fb
  • Loading branch information
Minion3665 committed Jun 28, 2024
1 parent 8628721 commit 2215fef
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion browser/src/control/Control.MobileWizardWindow.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ L.Control.MobileWizardWindow = L.Control.extend({
var parentNode = document.getElementById('mobile-wizard-content');
this.content = L.DomUtil.create('div', 'mobile-wizard mobile-wizard-content', parentNode);
this.content.id = this.id;

this.scrollPositions = [];
},

onAdd: function (map) {
Expand Down Expand Up @@ -253,6 +255,8 @@ L.Control.MobileWizardWindow = L.Control.extend({
else
$(contentToShow).children('.ui-content').first().show();

const currentScroll = this.mobileWizard.scrollTop();
this.scrollPositions.push(currentScroll);
this.mobileWizard.scrollTop(0);

this._currentDepth++;
Expand Down Expand Up @@ -325,7 +329,8 @@ L.Control.MobileWizardWindow = L.Control.extend({
$('#mobile-wizard.funcwizard div#mobile-wizard-content').addClass('hideHelpBG');
headers.show('slide', { direction: 'left' }, 'fast');

this.mobileWizard.scrollTop(0);
const prevScroll = this.scrollPositions.pop();
this.mobileWizard.scrollTop(prevScroll);

if (this._currentDepth == 0 || (this._isTabMode && this._currentDepth == 1)) {
this._inMainMenu = true;
Expand Down

0 comments on commit 2215fef

Please sign in to comment.