Skip to content

feat: Drag and drop: show collections in collapsed state#3136

Draft
matheusandre1 wants to merge 2 commits into
KaotoIO:mainfrom
matheusandre1:feature-2958
Draft

feat: Drag and drop: show collections in collapsed state#3136
matheusandre1 wants to merge 2 commits into
KaotoIO:mainfrom
matheusandre1:feature-2958

Conversation

@matheusandre1
Copy link
Copy Markdown
Contributor

@matheusandre1 matheusandre1 commented Apr 16, 2026

Closes: #2958

Summary by CodeRabbit

  • Style

    • Made the child-count badge size-adaptive (pill shape), added horizontal padding and improved spacing for multi-icon collections.
  • Bug Fixes

    • Child-count badge now appears only when a node is collapsed.
  • New Features

    • Added a small Layers icon indicator for nodes that contain nested groups.
  • Tests

    • Added tests covering collapse-state badge behavior and group-child detection.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 16, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 69f3aaad-69dc-44e7-ba34-d9f540aa1f86

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Propagates collapse state and group-child detection into node containers, conditions rendering of the child-count badge to only when collapsed, adds optional collection icon for nodes with group children, and adjusts FloatingCircle styles to size to content.

Changes

Cohort / File(s) Summary
Floating Circle Styling
packages/ui/src/components/Visualization/Custom/FloatingCircle/FloatingCircle.scss
Changed fixed 25px sizing to content-adaptive (min-width/min-height: 25px, width/height: fit-content, padding: 0 6px) and updated border-radius to 12.5px; added .step-icon-collection gap rule.
Node State Propagation
packages/ui/src/components/Visualization/Custom/Node/CustomNode.tsx, packages/ui/src/components/Visualization/Custom/Group/CustomGroupExpanded.tsx
Compute hasGroupChildren and forward isCollapsed and hasGroupChildren into CustomNodeContainer for both normal and dragged/overlay render paths.
Node Container Logic & Tests
packages/ui/src/components/Visualization/Custom/Node/CustomNodeContainer.tsx, packages/ui/src/components/Visualization/Custom/Node/CustomNodeContainer.test.tsx
Added isCollapsed: boolean and optional hasGroupChildren?: boolean props; render child-count FloatingCircle only when isCollapsed && childCount > 0; conditionally apply step-icon-collection and render Layers icon when hasGroupChildren is true; tests updated/added to cover collapsed and group-child cases.

Sequence Diagram(s)

sequenceDiagram
  participant Element
  participant CustomNode
  participant CustomNodeContainer
  participant FloatingCircle

  Element->>CustomNode: render with element data
  CustomNode->>CustomNodeContainer: pass props (childCount, isCollapsed, hasGroupChildren)
  alt Dragged overlay
    CustomNode->>CustomNodeContainer: render overlay (receives isCollapsed, hasGroupChildren)
  end
  CustomNodeContainer->>FloatingCircle: render if isCollapsed && childCount > 0
  alt hasGroupChildren
    FloatingCircle->>FloatingCircle: add .step-icon-collection class and render Layers icon
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • lordrip
  • lhein
  • igarashitm

Poem

🐰 I hop through nodes both near and far,
A badge that blooms when views are small and sparse,
If groups hide within, a tiny stack will show,
Layers hum softly so explorers know,
A rabbit winks — UI gleams with charm. ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main feature implementation: adding collection indicators to collapsed step nodes.
Linked Issues check ✅ Passed The code changes implement the requirements from issue #2958 by adding collection icon display in collapsed steps alongside node counters.
Out of Scope Changes check ✅ Passed All changes are directly related to displaying collections in collapsed states; no unrelated modifications are present.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
packages/ui/src/components/Visualization/Custom/Node/CustomNode.tsx (1)

138-139: Avoid calling getAllNodeChildren() twice.

Lines 138 and 139 each invoke element.getAllNodeChildren(). Reuse a single local to avoid duplicate traversal on every render.

♻️ Proposed refactor
-    const childCount = element.getAllNodeChildren().length;
-    const hasGroupChildren = element.getAllNodeChildren().some((node) => node.getData()?.vizNode?.data?.isGroup);
+    const nodeChildren = element.getAllNodeChildren();
+    const childCount = nodeChildren.length;
+    const hasGroupChildren = nodeChildren.some((node) => node.getData()?.vizNode?.data?.isGroup);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/ui/src/components/Visualization/Custom/Node/CustomNode.tsx` around
lines 138 - 139, The code calls element.getAllNodeChildren() twice when
computing childCount and hasGroupChildren; store the result in a local const
(e.g., const children = element.getAllNodeChildren()) and use children.length
for childCount and children.some(...) for hasGroupChildren so you avoid
repeating traversal in CustomNode (references: element.getAllNodeChildren,
childCount, hasGroupChildren).
packages/ui/src/components/Visualization/Custom/Node/CustomNodeContainer.test.tsx (1)

232-252: Consider tightening the svg assertion.

container.querySelector('svg') will match any SVG in the tree. Scoping the query to the .step-icon__collection element (e.g., container.querySelector('.step-icon__collection svg')) would more precisely assert that the Layers icon is rendered inside the collection badge and guard against false positives if other SVGs are introduced later.

♻️ Proposed refactor
-    expect(container.querySelector('.step-icon__collection')).toBeInTheDocument();
-    // Carbon icon is rendered inside PF Icon
-    expect(container.querySelector('svg')).toBeInTheDocument();
+    const collectionBadge = container.querySelector('.step-icon__collection');
+    expect(collectionBadge).toBeInTheDocument();
+    // Carbon Layers icon is rendered inside the PF Icon within the collection badge
+    expect(collectionBadge?.querySelector('svg')).toBeInTheDocument();
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@packages/ui/src/components/Visualization/Custom/Node/CustomNodeContainer.test.tsx`
around lines 232 - 252, The test "should render Layers icon when
hasGroupChildren is true" in CustomNodeContainer.test.tsx should scope the SVG
assertion to the collection badge: replace the broad
container.querySelector('svg') check with a scoped query such as
container.querySelector('.step-icon__collection svg') so the expectation ensures
the Layers icon is rendered inside the .step-icon__collection element rendered
by the CustomNodeContainer component when hasGroupChildren is true.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/ui/src/components/Visualization/Custom/Node/CustomNode.tsx`:
- Around line 138-139: The code calls element.getAllNodeChildren() twice when
computing childCount and hasGroupChildren; store the result in a local const
(e.g., const children = element.getAllNodeChildren()) and use children.length
for childCount and children.some(...) for hasGroupChildren so you avoid
repeating traversal in CustomNode (references: element.getAllNodeChildren,
childCount, hasGroupChildren).

In
`@packages/ui/src/components/Visualization/Custom/Node/CustomNodeContainer.test.tsx`:
- Around line 232-252: The test "should render Layers icon when hasGroupChildren
is true" in CustomNodeContainer.test.tsx should scope the SVG assertion to the
collection badge: replace the broad container.querySelector('svg') check with a
scoped query such as container.querySelector('.step-icon__collection svg') so
the expectation ensures the Layers icon is rendered inside the
.step-icon__collection element rendered by the CustomNodeContainer component
when hasGroupChildren is true.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4f875a9b-4c06-42b6-98e1-2c2a220b8b0f

📥 Commits

Reviewing files that changed from the base of the PR and between edea366 and e0f17d9.

📒 Files selected for processing (5)
  • packages/ui/src/components/Visualization/Custom/FloatingCircle/FloatingCircle.scss
  • packages/ui/src/components/Visualization/Custom/Group/CustomGroupExpanded.tsx
  • packages/ui/src/components/Visualization/Custom/Node/CustomNode.tsx
  • packages/ui/src/components/Visualization/Custom/Node/CustomNodeContainer.test.tsx
  • packages/ui/src/components/Visualization/Custom/Node/CustomNodeContainer.tsx

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@packages/ui/src/components/Visualization/Custom/Node/CustomNodeContainer.tsx`:
- Around line 57-68: The Layers icon is decorative but conveys semantics; update
the Icon wrapping the <Layers /> (inside the isCollapsed && childCount check) to
include an accessible label so screen readers know it represents nested
collections—e.g., add an aria-label or title like "contains nested collections"
(or a visually hidden span) on the Icon component used with hasGroupChildren
within CustomNodeContainer (the FloatingCircle / Icon / Layers block) so the
meaning is announced alongside the childCount.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b51a772f-f7a0-41b2-940a-ddeddafee547

📥 Commits

Reviewing files that changed from the base of the PR and between e6b10d1 and 36b65f7.

📒 Files selected for processing (5)
  • packages/ui/src/components/Visualization/Custom/FloatingCircle/FloatingCircle.scss
  • packages/ui/src/components/Visualization/Custom/Group/CustomGroupExpanded.tsx
  • packages/ui/src/components/Visualization/Custom/Node/CustomNode.tsx
  • packages/ui/src/components/Visualization/Custom/Node/CustomNodeContainer.test.tsx
  • packages/ui/src/components/Visualization/Custom/Node/CustomNodeContainer.tsx
🚧 Files skipped from review as they are similar to previous changes (3)
  • packages/ui/src/components/Visualization/Custom/Group/CustomGroupExpanded.tsx
  • packages/ui/src/components/Visualization/Custom/Node/CustomNode.tsx
  • packages/ui/src/components/Visualization/Custom/Node/CustomNodeContainer.test.tsx

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 23, 2026

Codecov Report

❌ Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 91.87%. Comparing base (e309e18) to head (36b65f7).
⚠️ Report is 39 commits behind head on main.

Files with missing lines Patch % Lines
...omponents/Visualization/Custom/Node/CustomNode.tsx 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3136      +/-   ##
==========================================
- Coverage   91.88%   91.87%   -0.01%     
==========================================
  Files         606      606              
  Lines       23350    23353       +3     
  Branches     5534     5344     -190     
==========================================
+ Hits        21454    21456       +2     
- Misses       1786     1895     +109     
+ Partials      110        2     -108     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@PVinaches
Copy link
Copy Markdown
Member

Hello @matheusandre1 ! Thanks for trying to address this issue. I have been testing it, but sadly it didn't work out. The icon is not showing when expected. If you run this branch and try to create a route with for example a choice and collapse it, you should see the label with the counter. Then, if you insert a second choice inside, you should see that number increased. If the code works, there should appear the layer icon next to the number, but it is not showing. The main issues are related to hasGroupChildren, because the isGroup parameter is not checking for nested child inside groups, and isCollapsed, because for example a choice is rendered as a regular node.

@igarashitm igarashitm marked this pull request as draft April 30, 2026 13:03
@github-actions
Copy link
Copy Markdown
Contributor

This pull request is stale because it has been open for 14 days with no activity. It will be closed if there is no activity in the next 14 days.

@github-actions github-actions Bot added stale Marks issues that were not updated for a long time. and removed stale Marks issues that were not updated for a long time. labels May 14, 2026
Signed-off-by: Matheus André <matheusandr2@gmail.com>
@sonarqubecloud
Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Drag and drop: show collections in collapsed state

2 participants