Skip to content

Commit 18c3b6f

Browse files
committed
Don't apply simple/nested pattern for unaffected children group
1 parent e71a870 commit 18c3b6f

File tree

1 file changed

+14
-3
lines changed
  • workflow-trace-viewer/src/jvmMain/kotlin/com/squareup/workflow1/traceviewer/ui

1 file changed

+14
-3
lines changed

workflow-trace-viewer/src/jvmMain/kotlin/com/squareup/workflow1/traceviewer/ui/WorkflowTree.kt

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,8 @@ private fun DrawTree(
208208
/**
209209
* Draws the group of unaffected children, which can be open and closed to expand/collapse them.
210210
*
211-
* If an unaffected children also has other children, it cannot be opened, since the this group
212-
* treats all nodes as one entity, so the onClick for the whole group overrides the onClick for the
211+
* If an unaffected children also has other children, it cannot be opened since the this group
212+
* treats all nodes as one entity. The onClick for the whole group overrides the onClick for the
213213
* individual nodes.
214214
*/
215215
@OptIn(ExperimentalComposeUiApi::class)
@@ -266,6 +266,7 @@ private fun UnaffectedChildrenGroup(
266266
previousFrameNode = previousFrameNode,
267267
affectedNodes = affectedNodes,
268268
expandedNodes = expandedNodes,
269+
unaffected = true,
269270
onNodeSelect = onNodeSelect
270271
)
271272
}
@@ -297,17 +298,27 @@ private fun AffectedChildrenGroup(
297298

298299
/**
299300
* Draws the children in a grid manner, to avoid horizontal clutter and make better use of space.
301+
*
302+
* Unaffected children group would call this with `unaffected = true`, which means that simple/nested
303+
* nodes don't matter since we can't open nested ones, so we just simply group in 5's
300304
*/
301305
@Composable
302306
private fun DrawChildrenInGroups(
303307
children: List<Node>,
304308
previousFrameNode: Node?,
305309
affectedNodes: Set<Node>,
306310
expandedNodes: MutableMap<String, Boolean>,
311+
unaffected: Boolean = false,
307312
onNodeSelect: (NodeUpdate) -> Unit
308313
) {
309314
// Split children into those with children (nested) and those without
310-
val (nestedChildren, simpleChildren) = children.partition { it.children.isNotEmpty() }
315+
var (nestedChildren, simpleChildren) = children.partition { it.children.isNotEmpty() }
316+
317+
// Just reset the lists so we chunk everything in the unaffected group
318+
if (unaffected) {
319+
nestedChildren = emptyList()
320+
simpleChildren = children
321+
}
311322

312323
Column(
313324
verticalArrangement = Arrangement.spacedBy(16.dp), // Increased spacing between sections

0 commit comments

Comments
 (0)