Skip to content

Commit

Permalink
Stop scrollbar from causing content shift
Browse files Browse the repository at this point in the history
When a note reaches the point where a scrollbar is needed the entire application shifts to the left slightly to accommodate the width of the scrollbar.

This uses the `overflow-y: overlay`  css property which was recently readded to Chrome, though it doesn't have compatibility with other browsers and is simply left with `overflow-y: auto` elsewhere.

In the future browsers will implement `scrollbar-gutter` which should be a globally available method of fixing this problem but that is still likely quite far away.
  • Loading branch information
zolrath authored and tiensonqin committed May 25, 2021
1 parent b5099a8 commit 4223540
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/electron/electron/core.cljs
Expand Up @@ -36,6 +36,9 @@
:nodeIntegrationInWorker false
:contextIsolation true
:spellcheck true
;; Remove OverlayScrollbars and transition `.scrollbar-spacing`
;; to use `scollbar-gutter` after the feature is implemented in browsers.
:enableBlinkFeatures 'OverlayScrollbars'
:preload (path/join js/__dirname "js/preload.js")}}
linux?
(assoc :icon (path/join js/__dirname "icons/logseq.png")))
Expand Down
2 changes: 1 addition & 1 deletion src/main/frontend/components/sidebar.cljs
Expand Up @@ -314,7 +314,7 @@
:route-match route-match})
[:div.#app-container.h-screen.flex
[:div.flex-1.h-full.flex.flex-col.overflow-y-auto#left-container.relative
[:div
[:div.scrollbar-spacing
(header/header {:open-fn open-fn
:white? white?
:current-repo current-repo
Expand Down
13 changes: 13 additions & 0 deletions src/main/frontend/components/sidebar.css
Expand Up @@ -198,3 +198,16 @@
.cp__sidebar-main-content[data-is-global-graph-pages='true'] {
padding: 0;
}

@supports not (overflow-y: overlay) {
.scrollbar-spacing {
overflow-y: auto;
}
}

@supports (overflow-y: overlay) {
.scrollbar-spacing {
overflow-y: overlay;
}
}

0 comments on commit 4223540

Please sign in to comment.