Skip to content

Conversation

@1307-Dev
Copy link
Collaborator

💡 What is the current behavior?

While using custom tree, clicking on tree-items doesn't trigger selection of these tree items.

GitHub Issue Number: #2098

🆕 What is the new behavior?

Click events are now registered and the tree items are now selectable.

🏁 Checklist

A pull request can only be merged if all of these conditions are met (where applicable):

  • 🦮 Accessibility (a11y) features were implemented
  • 🗺️ Internationalization (i18n) - no hard coded strings
  • 📲 Responsiveness - components handle viewport changes and content overflow gracefully
  • 📕 Add or update a Storybook story
  • 📄 Documentation was reviewed/updated siemens/ix-docs
  • 🧪 Unit tests were added/updated and pass (pnpm test)
  • 📸 Visual regression tests were added/updated and pass (Guide)
  • 🧐 Static code analysis passes (pnpm lint)
  • 🏗️ Successful compilation (pnpm build, changes pushed)

👨‍💻 Help & support

@changeset-bot
Copy link

changeset-bot bot commented Nov 11, 2025

🦋 Changeset detected

Latest commit: cf72143

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@siemens/ix Patch
@siemens/ix-angular Patch
@siemens/ix-docs Patch
@siemens/ix-react Patch
@siemens/ix-vue Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@sonarqubecloud
Copy link

@1307-Dev 1307-Dev changed the title Added fix and test fix(core/tree)- Fixed tree-items in custom tree component. Nov 11, 2025
@1307-Dev 1307-Dev marked this pull request as ready for review November 17, 2025 05:28
Copy link
Collaborator

@nuke-ellington nuke-ellington left a comment

Choose a reason for hiding this comment

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

  1. Resolve conflicts
  2. Fix change requests

@nuke-ellington nuke-ellington added this to the 4.4.0 milestone Jan 26, 2026
@nuke-ellington
Copy link
Collaborator

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request fixes an issue where custom-rendered tree items were not selectable. The fix involves a new getTreeNodeId method to correctly identify the tree node from a click event, even when the click target is a nested element within a custom tree item. The changes are logical and include a new test case to validate the fix. I have one suggestion to refactor the new getTreeNodeId method for improved readability and type safety.

@sonarqubecloud
Copy link

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes ix-tree selection for custom-rendered tree items by resolving the clicked tree node id from nested click targets (matching Issue #2098).

Changes:

  • Add DOM-walk helper to resolve data-tree-node-id from an event target’s ancestor chain.
  • Use the helper for both toggle and item click handling to correctly select nodes when clicking nested custom content.
  • Add a component regression test and a patch changeset entry.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
packages/core/src/components/tree/tree.tsx Introduces getTreeNodeId() and uses it to correctly map clicks/toggles to the owning tree item id.
packages/core/src/components/tree/test/tree.ct.ts Adds a regression test intended to validate click selection for custom-rendered tree items.
.changeset/fair-apricots-walk.md Patch release note for enabling selection via mouse click on custom ix-tree-items.

Comment on lines +508 to +510
const customItem = tree.locator('ix-tree-item').nth(1);
await customItem.click();
await expect(customItem).toHaveClass(/selected/);
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

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

This new regression test clicks the ix-tree-item host (customItem.click()), but the reported issue was that clicks on child elements inside a custom-rendered item (e.g. the nested span/div) were not registered because the event target didn’t carry data-tree-node-id. To actually cover the regression, trigger the click on the nested .custom-content (or its span) and assert selection on the parent tree item; optionally assert the custom content is present so the test guarantees the custom renderer is in use.

Copilot uses AI. Check for mistakes.
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.

3 participants