Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
overlays: Stop document from occupying the extra scrollbar width.
Aman Agrawal8654f839b5bd
diff --git a/web/src/overlays.ts b/web/src/overlays.tsindex 22a6d8f68f7..bdad57d7705 100644--- a/web/src/overlays.ts+++ b/web/src/overlays.ts@@ -50,11 +50,17 @@ function call_hooks(func_list: Hook[]): void {}export function disable_scrolling(): void {- $("html").css({"overflow-y": "hidden"});+ // Why disable scrolling?+ // Since fixed / absolute positined elements don't capture the scroll event unless+ // they overflow their defined container. Since fixed / absolute elements are not treated+ // as part of the document flow, we cannot capture `scroll` events on them and prevent propagation+ // as event bubbling doesn't work naturally.+ const scrollbar_width = window.innerWidth - document.documentElement.clientWidth;+ $("html").css({"overflow-y": "hidden", "--disabled-scrollbar-width": `${scrollbar_width}px`});}function enable_scrolling(): void {- $("html").css({"overflow-y": "scroll"});+ $("html").css({"overflow-y": "scroll", "--disabled-scrollbar-width": "0px"});}export function is_active(): boolean {diff --git a/web/styles/compose.css b/web/styles/compose.cssindex ad673186d16..0c146d38f62 100644--- a/web/styles/compose.css+++ b/web/styles/compose.css@@ -227,7 +227,6 @@bottom: 0;left: 0;z-index: 4;- width: 100%;}#compose-container {diff --git a/web/styles/zulip.css b/web/styles/zulip.cssindex 09b2a2de5d7..3fe26443e5e 100644--- a/web/styles/zulip.css+++ b/web/styles/zulip.css@@ -2,11 +2,11 @@ html {overflow-y: scroll;overflow-x: hidden;overscroll-behavior-y: none;+ width: calc(100% - var(--disabled-scrollbar-width));}body,html {- width: 100%;height: 100%;touch-action: manipulation;}@@ -21,6 +21,7 @@ html {}body {+ width: 100%;font-size: 14px;line-height: calc(20 / 14);font-family: "Source Sans 3", sans-serif;@@ -90,6 +91,13 @@ body {*/--compose-recipient-box-min-height: 30.5px;+ /*+ Width to be reserved for document scrollbar when scrolling is disabled.+ Using `scrollbar-gutter` would be more appropriate but doesn't has wide+ support and doesn't work for `fixed` elements.+ */+ --disabled-scrollbar-width: 0px;+/* Colors used across the app */--color-background-private-message-header: hsl(46deg 35% 93%);--color-background-private-message-content: hsl(45deg 20% 96%);@@ -389,7 +397,13 @@ p.n-margin {position: fixed;top: 0;z-index: 102;- width: 100%;+}++/* Adjust width of any fixed / absolute positioned elements that might be visible in+ the background when a overlay / modal is open. */+#navbar-fixed-container,+#compose {+ width: calc(100% - var(--disabled-scrollbar-width));}.header {