Skip to content
This repository was archived by the owner on Sep 21, 2021. It is now read-only.

Commit c59a025

Browse files
committed
Fix style for non-expandable root nodes in Tree component.
Fixes #886. If a Tree contained multiple roots, some expandables, some not, the non-expandable node weren't aligned to the expanded one. This is because we align non-expandable items adding a margin to the last tree-indent element of the node. However, non-expandable root do not have any tree-indent element child, so they were missing a margin. This patch adds a specific margin-inline-start for non-expandable root nodes. The multiple root tree story is modified to also include non-expandable root nodes.
1 parent 8a48e83 commit c59a025

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

packages/devtools-components/src/tree.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@
4343
margin-inline-end: 15px;
4444
}
4545

46+
/* For non expandable root nodes, we don't have .tree-indent elements, so we declare
47+
the margin on the start of the node */
48+
.tree-node[data-expandable="false"][aria-level="0"] {
49+
padding-inline-start: 15px
50+
}
51+
4652
.tree .tree-node[data-expandable="true"] {
4753
cursor: default;
4854
}

packages/devtools-components/stories/tree.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ storiesOf("Tree", module)
2828
.add("Multiple root tree", () => {
2929
return renderTree({
3030
autoExpandDepth: Infinity,
31-
getRoots: () => ["A", "W"],
31+
getRoots: () => ["A", "P", "M", "Q", "W", "R"],
3232
});
3333
})
3434
.add("focused node", () => {
@@ -133,6 +133,13 @@ storiesOf("Tree", module)
133133
// M
134134
// `-- N
135135
// `-- O
136+
// P
137+
// Q
138+
// R
139+
// W
140+
// `-- X
141+
// `-- Z
142+
// `-- Y
136143
const TEST_TREE = {
137144
children: {
138145
A: ["B", "C", "D"],
@@ -150,6 +157,9 @@ const TEST_TREE = {
150157
M: ["N"],
151158
N: ["O"],
152159
O: [],
160+
P: [],
161+
Q: [],
162+
R: [],
153163
W: ["X", "Y"],
154164
X: ["Z"],
155165
Y: [],
@@ -171,6 +181,9 @@ const TEST_TREE = {
171181
M: null,
172182
N: "M",
173183
O: "N",
184+
P: null,
185+
Q: null,
186+
R: null,
174187
W: null,
175188
X: "W",
176189
Y: "W",

0 commit comments

Comments
 (0)