Skip to content

Commit 0655bd0

Browse files
committed
enable scroll on document tabs and auto-scroll to active tab
1 parent b050e72 commit 0655bd0

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

src/renderer/document/views.cljs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
["@radix-ui/react-dropdown-menu" :as DropdownMenu]
55
[re-frame.core :as rf]
66
[reagent.core :as ra]
7+
[renderer.app.events :as-alias app.e]
78
[renderer.document.events :as-alias e]
89
[renderer.document.subs :as-alias s]
910
[renderer.history.events :as-alias history.e]
@@ -108,7 +109,10 @@
108109
(let [dropped-id (-> (.-dataTransfer evt) (.getData "id") uuid)]
109110
(.preventDefault evt)
110111
(reset! dragged-over? false)
111-
(rf/dispatch [::e/swap-position dropped-id id])))}
112+
(rf/dispatch [::e/swap-position dropped-id id])))
113+
:ref (fn [this]
114+
(when (and this active?)
115+
(rf/dispatch [::app.e/scroll-into-view this])))}
112116
[:span.truncate.pointer-events-none title]
113117
[close-button id saved?]]]
114118
[:> ContextMenu/Portal
@@ -124,12 +128,15 @@
124128
(let [documents @(rf/subscribe [::s/entities])
125129
tabs @(rf/subscribe [::s/tabs])
126130
active-id @(rf/subscribe [::s/active-id])]
127-
[:div.flex.drag.justify-between
128-
[:div.flex.flex-1.gap-px.overflow-hidden
129-
(for [document-id tabs]
130-
(let [title (:title (get documents document-id))
131-
active? (= document-id active-id)]
132-
^{:key (str document-id)} [tab document-id title active?]))]
131+
[:div.flex.justify-between.gap-px
132+
[ui/scroll-area
133+
[:div.flex.flex-1.gap-px
134+
{:class "h-[41px]"}
135+
(for [document-id tabs]
136+
(let [title (:title (get documents document-id))
137+
active? (= document-id active-id)]
138+
^{:key (str document-id)} [tab document-id title active?]))
139+
[:div.drag.flex-1]]]
133140
[:div.toolbar
134141
[:> DropdownMenu/Root
135142
[:> DropdownMenu/Trigger

0 commit comments

Comments
 (0)