Skip to content

Commit bf1371d

Browse files
committed
Fixed firefox tri-layout grid issue and added tablet sticky sidebar
- Fixed issue with original left-sidebar content being placed halfway down the page. - Added sticky sidebar to mid-size tablet layout, only for original left sidebar items. Fixes BookStackApp#1434.
1 parent f086687 commit bf1371d

3 files changed

Lines changed: 22 additions & 10 deletions

File tree

resources/assets/js/components/page-display.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,11 @@ class PageDisplay {
2323
const sidebarPageNav = document.querySelector('.sidebar-page-nav');
2424
if (sidebarPageNav) {
2525
DOM.onChildEvent(sidebarPageNav, 'a', 'click', (event, child) => {
26+
event.preventDefault();
2627
window.components['tri-layout'][0].showContent();
27-
this.goToText(child.getAttribute('href').substr(1));
28+
const contentId = child.getAttribute('href').substr(1);
29+
this.goToText(contentId);
30+
window.history.pushState(null, null, '#' + contentId);
2831
});
2932
}
3033
}

resources/assets/js/components/tri-layout.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,14 @@ class TriLayout {
7474
* Used by the page-display component.
7575
*/
7676
showContent() {
77-
this.showTab('content');
77+
this.showTab('content', false);
7878
}
7979

8080
/**
8181
* Show the given tab
8282
* @param tabName
8383
*/
84-
showTab(tabName) {
84+
showTab(tabName, scroll = true) {
8585
this.scrollCache[this.lastTabShown] = document.documentElement.scrollTop;
8686

8787
// Set tab status
@@ -96,12 +96,14 @@ class TriLayout {
9696
this.elem.classList.toggle('show-info', showInfo);
9797

9898
// Set the scroll position from cache
99-
const pageHeader = document.querySelector('header');
100-
const defaultScrollTop = pageHeader.getBoundingClientRect().bottom;
101-
document.documentElement.scrollTop = this.scrollCache[tabName] || defaultScrollTop;
102-
setTimeout(() => {
99+
if (scroll) {
100+
const pageHeader = document.querySelector('header');
101+
const defaultScrollTop = pageHeader.getBoundingClientRect().bottom;
103102
document.documentElement.scrollTop = this.scrollCache[tabName] || defaultScrollTop;
104-
}, 50);
103+
setTimeout(() => {
104+
document.documentElement.scrollTop = this.scrollCache[tabName] || defaultScrollTop;
105+
}, 50);
106+
}
105107

106108
this.lastTabShown = tabName;
107109
}

resources/assets/sass/_layout.scss

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,12 +219,19 @@ body.flexbox {
219219
@include smaller-than($xxl) {
220220
.tri-layout-container {
221221
grid-template-areas: "c b b"
222-
"a b b";
222+
"a b b"
223+
". b b";
223224
grid-template-columns: 1fr 3fr;
224-
grid-template-rows: max-content min-content;
225+
grid-template-rows: min-content min-content 1fr;
225226
padding-right: $-l;
226227
}
227228
}
229+
@include between($l, $xxl) {
230+
.tri-layout-left {
231+
position: sticky;
232+
top: $-m;
233+
}
234+
}
228235
@include larger-than($xxl) {
229236
.tri-layout-left-contents, .tri-layout-right-contents {
230237
padding: $-m;

0 commit comments

Comments
 (0)