From 1f103231e4ffaecd9d2272728d679d4a88e1827d Mon Sep 17 00:00:00 2001 From: Waseem Daher Date: Mon, 21 Jan 2013 18:51:15 -0500 Subject: [PATCH] Unbreak scroll-position-restoring for the settings page. (imported from commit 81dcf4d81189764710506294ee4f9400ecd5d883) --- zephyr/static/js/ui.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/zephyr/static/js/ui.js b/zephyr/static/js/ui.js index a18cd398ca..f792d8438f 100644 --- a/zephyr/static/js/ui.js +++ b/zephyr/static/js/ui.js @@ -611,13 +611,7 @@ $(function () { scroll_positions[old_tab] = viewport.scrollTop(); }); $('#gear-menu a[data-toggle="tab"]').on('shown', function (e) { - // Right after we show the new tab, restore its old scroll position var target_tab = $(e.target).attr('href'); - if (scroll_positions.hasOwnProperty(target_tab)) { - viewport.scrollTop(scroll_positions[target_tab]); - } else { - viewport.scrollTop(0); - } // Hide all our error messages when switching tabs $('.alert-error').hide(); @@ -638,6 +632,15 @@ $(function () { browser_url = ""; } hashchange.changehash(browser_url); + + // After we show the new tab, restore its old scroll position + // (we apparently have to do this after setting the hash, + // because otherwise that action may scroll us somewhere.) + if (scroll_positions.hasOwnProperty(target_tab)) { + viewport.scrollTop(scroll_positions[target_tab]); + } else { + viewport.scrollTop(0); + } }); // N.B. that subs.setup_page calls focus() on our stream textbox,