diff --git a/frontend/src/app/main/ui/workspace/viewport/scroll_bars.cljs b/frontend/src/app/main/ui/workspace/viewport/scroll_bars.cljs index aefaf4ddf7..0012c0472e 100644 --- a/frontend/src/app/main/ui/workspace/viewport/scroll_bars.cljs +++ b/frontend/src/app/main/ui/workspace/viewport/scroll_bars.cljs @@ -51,7 +51,7 @@ vbox-x (:x vbox) vbox-y (:y vbox) - base-objects-rect (mf/with-memo [objects] + shapes-rect (mf/with-memo [objects] (-> objects (cfh/get-immediate-children) (gsh/shapes->rect))) @@ -65,6 +65,11 @@ vbox-height (- (:height vbox) (* inv-zoom scroll-height)) vbox-width (- (:width vbox) (* inv-zoom scroll-width)) + ;; When there are no shapes there is no content to scroll to, so use a + ;; rect matching the viewport itself, which keeps every offset below at 0 + base-objects-rect (or shapes-rect + (grc/make-rect vbox-x vbox-y vbox-width vbox-height)) + ;; top space hidden because of the scroll top-offset (-> (- vbox-y (:y base-objects-rect)) (max 0)