Commit cdf44d9f authored by Luke Howell's avatar Luke Howell

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
parent 1fed9753
...@@ -10,6 +10,7 @@ v 8.13.0 (unreleased) ...@@ -10,6 +10,7 @@ v 8.13.0 (unreleased)
- Avoid database queries on Banzai::ReferenceParser::BaseParser for nodes without references - Avoid database queries on Banzai::ReferenceParser::BaseParser for nodes without references
- Fix permission for setting an issue's due date - Fix permission for setting an issue's due date
- Expose expires_at field when sharing project on API - Expose expires_at field when sharing project on API
- Fix issue with page scrolling to top when closing or pinning sidebar (lukehowell)
- Allow the Koding integration to be configured through the API - Allow the Koding integration to be configured through the API
- Added soft wrap button to repository file/blob editor - Added soft wrap button to repository file/blob editor
- Fix robots.txt disallowing access to groups starting with "s" (Matt Harrison) - Fix robots.txt disallowing access to groups starting with "s" (Matt Harrison)
......
...@@ -34,8 +34,8 @@ ...@@ -34,8 +34,8 @@
$(pageSelector).hasClass(expandedPageClass) $(pageSelector).hasClass(expandedPageClass)
); );
$(document) $(document)
.on('click', sidebarToggleSelector, () => this.toggleSidebar()) .on('click', sidebarToggleSelector, (e) => this.toggleSidebar(e))
.on('click', pinnedToggleSelector, () => this.togglePinnedState()) .on('click', pinnedToggleSelector, (e) => this.togglePinnedState(e))
.on('click', 'html, body', (e) => this.handleClickEvent(e)) .on('click', 'html, body', (e) => this.handleClickEvent(e))
.on('page:change', () => this.renderState()); .on('page:change', () => this.renderState());
this.renderState(); this.renderState();
...@@ -47,17 +47,19 @@ ...@@ -47,17 +47,19 @@
const targetIsToggle = $target.closest(sidebarToggleSelector).length > 0; const targetIsToggle = $target.closest(sidebarToggleSelector).length > 0;
const targetIsSidebar = $target.closest(sidebarWrapperSelector).length > 0; const targetIsSidebar = $target.closest(sidebarWrapperSelector).length > 0;
if (!targetIsToggle && (!targetIsSidebar || $target.closest('a'))) { if (!targetIsToggle && (!targetIsSidebar || $target.closest('a'))) {
this.toggleSidebar(); this.toggleSidebar(e);
} }
} }
} }
toggleSidebar() { toggleSidebar(e) {
e.preventDefault();
this.isExpanded = !this.isExpanded; this.isExpanded = !this.isExpanded;
this.renderState(); this.renderState();
} }
togglePinnedState() { togglePinnedState(e) {
e.preventDefault();
this.isPinned = !this.isPinned; this.isPinned = !this.isPinned;
if (!this.isPinned) { if (!this.isPinned) {
this.isExpanded = false; this.isExpanded = false;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment