Skip to content

Commit 7df9a1d

Browse files
committed
[nested-v-grid] Fix branch-paths appearing in the wrong place
1 parent 89c3eb8 commit 7df9a1d

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

src/re_com/nested_v_grid/util.cljc

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44
goog.string])))
55

66
(defn keypath->grid-line-name [keypath]
7-
(str/join "-" (into ["rc"] keypath)))
7+
(->> keypath
8+
(into (if (:branch-end? (meta keypath))
9+
["rc-b"]
10+
["rc"]))
11+
(str/join "-")))
812

913
(defn path->grid-line-name [path]
1014
(str "rc" (hash path)))
@@ -124,22 +128,21 @@
124128
(header-size node default-size))]
125129
(when (or (intersection? sum leaf-size window-start window-end)
126130
collect-anyway?)
127-
(let [new-path (cond-> (mapv remove-size leaf-path)
131+
(let [path-meta (merge (if is-leaf? {:leaf? true} {:branch? true})
132+
(when branch-end? {:branch-end? true})
133+
(when show-above? {:show-above? true})
134+
(when last-child? {:last-child? true}))
135+
new-path (cond-> (mapv remove-size leaf-path)
128136
(or is-leaf? show-above?)
129-
(vary-meta merge {}
130-
(when is-leaf? {:leaf? true})
131-
(when-not is-leaf? {:branch? true})
132-
(when branch-end? {:branch-end? true})
133-
(when show-above? {:show-above? true})
134-
(when last-child? {:last-child? true})))]
137+
(vary-meta merge path-meta))]
135138
#_(when show?
136139
(vswap! spans
137140
(fn [m] (reduce #(update %1 %2 inc) m (ancestry leaf-path)))))
138141
(vswap! depth max cached-depth (count new-path))
139142
(vswap! paths conj new-path)
140143
(vswap! sums conj sum)
141144
(vswap! sizes conj leaf-size)
142-
(vswap! keypaths conj keypath)))
145+
(vswap! keypaths conj (vary-meta keypath merge path-meta))))
143146
(vswap! sum-size + leaf-size)
144147
leaf-size))))]
145148
(walk [] header-tree {:hide? hide-root?})
@@ -179,9 +182,10 @@
179182
(defn grid-template [header-traversal]
180183
(str/replace
181184
(str/join " "
182-
(map #(cond (string? %) %
185+
(map #(do
186+
(cond (string? %) %
183187
(vector? %) (str "[" (keypath->grid-line-name %) "]")
184-
(number? %) (str % "px"))
188+
(number? %) (str % "px")))
185189
(grid-tokens header-traversal)))
186190
"] [" " "))
187191

0 commit comments

Comments
 (0)