diff options
author | Luke Howell <luke.howell@gmail.com> | 2016-09-30 21:54:57 -0500 |
---|---|---|
committer | Luke Howell <luke.howell@gmail.com> | 2016-10-01 15:25:07 -0500 |
commit | cdf44d9fe512398115efeb03112a3b2b7d631f92 (patch) | |
tree | d8be22471755a68e9bb78a0d8549f5f6e9b45c6c /app | |
parent | 1fed97530af84b7660e45a9a8d4e3dafbed026f7 (diff) | |
download | gitlab-ce-cdf44d9fe512398115efeb03112a3b2b7d631f92.tar.gz |
Fix page scrolling to top on sidebar toggle
Added preventDefault for toggling sidebar off as well as for pinning
and unpinning the sidebar.
Closes #22851
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/sidebar.js.es6 | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/app/assets/javascripts/sidebar.js.es6 b/app/assets/javascripts/sidebar.js.es6 index 755fac8107b..ead3219bc31 100644 --- a/app/assets/javascripts/sidebar.js.es6 +++ b/app/assets/javascripts/sidebar.js.es6 @@ -34,8 +34,8 @@ $(pageSelector).hasClass(expandedPageClass) ); $(document) - .on('click', sidebarToggleSelector, () => this.toggleSidebar()) - .on('click', pinnedToggleSelector, () => this.togglePinnedState()) + .on('click', sidebarToggleSelector, (e) => this.toggleSidebar(e)) + .on('click', pinnedToggleSelector, (e) => this.togglePinnedState(e)) .on('click', 'html, body', (e) => this.handleClickEvent(e)) .on('page:change', () => this.renderState()); this.renderState(); @@ -47,17 +47,19 @@ const targetIsToggle = $target.closest(sidebarToggleSelector).length > 0; const targetIsSidebar = $target.closest(sidebarWrapperSelector).length > 0; if (!targetIsToggle && (!targetIsSidebar || $target.closest('a'))) { - this.toggleSidebar(); + this.toggleSidebar(e); } } } - toggleSidebar() { + toggleSidebar(e) { + e.preventDefault(); this.isExpanded = !this.isExpanded; this.renderState(); } - togglePinnedState() { + togglePinnedState(e) { + e.preventDefault(); this.isPinned = !this.isPinned; if (!this.isPinned) { this.isExpanded = false; |