Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
scroll_bar: Fix overlapping right sidebar and browser scrollbars.
Aman Agrawal230b3f075bf9
diff --git a/web/src/scroll_bar.ts b/web/src/scroll_bar.tsindex 485e86d00f9..78933fb8ac9 100644--- a/web/src/scroll_bar.ts+++ b/web/src/scroll_bar.ts@@ -10,6 +10,27 @@ export function set_layout_width(): void {}}+export function handle_overlay_scrollbars(): void {+ // If right sidebar scrollbar overlaps with browser scrollbar, move the right+ // sidebar scrollbar to the left. Done on fluid screen width and when scrollbars overlap.+ const scrollbar_width = window.innerWidth - document.documentElement.clientWidth;+ if (scrollbar_width === 0) {+ const max_app_width = 1400;+ const max_scrollbar_width = 20;+ const are_scrollbars_overlapping = window.innerWidth < max_app_width + max_scrollbar_width;+ if (user_settings.fluid_layout_width || are_scrollbars_overlapping) {+ $("body").addClass("has-overlay-scrollbar");+ return;+ }+ }++ $("body").removeClass("has-overlay-scrollbar");+}+export function initialize(): void {set_layout_width();+ handle_overlay_scrollbars();+ const middle_column = $(".app .column-middle").expectOne()[0];+ const resize_observer = new ResizeObserver(handle_overlay_scrollbars);+ resize_observer.observe(middle_column);}diff --git a/web/styles/zulip.css b/web/styles/zulip.cssindex eb442174884..5ceb9776624 100644--- a/web/styles/zulip.css+++ b/web/styles/zulip.css@@ -105,6 +105,15 @@ body {*/--disabled-scrollbar-width: 0px;+ /*+ Right offset of simplebar scrollbar for `.column-right` when browser has+ overlay scrollbars which don't occupy any space. Currently only+ known to present on Mac (all browsers) and Firefox (all OS?). This seems+ more than enough to differentiate right sidebar scrollbar and browser+ scrollbar even if the browser scrollbar is wider.+ */+ --browser-overlay-scrollbar-width: 10px;+/* Colors used across the app */--color-background-private-message-header: hsl(46deg 35% 93%);--color-background-private-message-content: hsl(45deg 20% 96%);@@ -553,6 +562,14 @@ p.n-margin {position: relative;}+body.has-overlay-scrollbar {+ /* Move simplebar scrollbar to the left so that+ browser scrollbar doesn't overlap with it. */+ .column-right .simplebar-track.simplebar-vertical {+ right: var(--browser-overlay-scrollbar-width);+ }+}+.column-right {width: var(--right-sidebar-width);max-width: var(--right-sidebar-width);@@ -2853,6 +2870,10 @@ select.invite-as {right: 15px;top: 0;+ .simplebar-track.simplebar-vertical {+ right: 0;+ }+.right-sidebar {box-shadow: 0 -2px 3px 0 hsl(0deg 0% 0% / 10%);border-left: 1px solid hsl(0deg 0% 87%);