Skip to content

feat(core/tree) Improve keyboard activation for node selection and expand/collapse for tree-item - #2665

Merged
lzeiml merged 37 commits into
mainfrom
ix-4342-tree
Oct 21, 2026
Merged

lzeiml merged 37 commits into
mainfrom
ix-4342-tree

Conversation

@1307-Dev

@1307-Dev 1307-Dev commented Jul 21, 2026 •

Copy link
Copy Markdown
Collaborator

💡 What is the current behavior?

Pressing Space or Enter while a tree item row or expand/collapse chevron has keyboard focus has no effect.

GitHub Issue Number: #

🆕 What is the new behavior?

tree-node-container now has selection logic

tree's chevron now expands/collapses on enter keydown

focus has been applied to these two.

🏁 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)

Summary by CodeRabbit

  • Accessibility
    • Enabled Enter/Space activation for tree chevrons and node containers.
    • Added consistent focus-visible styling for keyboard navigation.
    • Preserved focus across tree refreshes to prevent unexpected focus loss.
    • Improved screen-reader announcements for expanded and disabled controls.
  • Tests
    • Added accessibility checks and keyboard regression tests covering expansion, selection, disabled nodes, and focus restoration after refresh.

@netlify

netlify Bot commented Jul 21, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for ix-storybook ready!

Name Link
🔨 Latest commit c5c65ab
🔍 Latest deploy log https://app.netlify.com/projects/ix-storybook/deploys/6ad87bca4da58a209e3cf704
😎 Deploy Preview https://deploy-preview-2665--ix-storybook.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@changeset-bot

changeset-bot Bot commented Jul 21, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: c5c65ab

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

This PR includes changesets to release 4 packages
Name Type
@siemens/ix Minor
@siemens/ix-angular Minor
@siemens/ix-react Minor
@siemens/ix-vue Minor

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

@coderabbitai

coderabbitai Bot commented Jul 21, 2026 •

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: b719948d-eed4-489d-b0f6-5b3fbc4d2eab

📥 Commits

Reviewing files that changed from the base of the PR and between 89d18c9 and 617ed11.

📒 Files selected for processing (2)
  • packages/core/src/components/tree/test/tree.ct.ts
  • packages/core/src/components/tree/tree.tsx

Included review availability: Your plan provides up to 2 included reviews per hour; 0 remain after this review.

📝 Walkthrough

Tree items now support keyboard activation, accessible button semantics, and focus-visible styling. Tree refreshes preserve focus on the corresponding chevron or node container after the virtualized list is refreshed.

Changes: Tree accessibility

Layer / File(s) Summary
Tree item keyboard semantics and focus styling
packages/core/src/components/tree-item/tree-item.scss, packages/core/src/components/tree-item/tree-item.tsx, packages/core/src/components/tree/test/tree.ct.ts
Tree controls receive disabled-aware tab indices, button roles, ARIA attributes, Space/Enter handlers, focus-visible styling, and accessibility and interaction coverage.
Focus preservation during tree refresh
packages/core/src/components/tree/tree.tsx, packages/core/src/components/tree/test/tree.ct.ts
Tree refreshes record whether focus was on a node container or chevron icon, then restore focus to the matching refreshed element.
Accessibility release metadata
.changeset/keyboard-tree-item-a11y.md
A patch changeset records the tree keyboard and accessibility updates.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Document
  participant Tree
  participant VirtualizedList
  participant TreeItem
  Tree->>Document: Inspect activeElement and shadow DOM
  Tree->>VirtualizedList: Refresh tree
  VirtualizedList-->>Tree: Return refreshed tree DOM
  Tree->>TreeItem: Focus matching chevron or node container
Loading

Possibly related PRs

  • siemens/ix#2612: Updates related focus-refresh logic and tree tests in tree.tsx and tree.ct.ts.
  • siemens/ix#2681: Adds related keyboard accessibility and ARIA behavior for interactive tree controls.

Suggested reviewers: danielleroux, nuke-ellington

Merge Risk: 🔵 Low · up to 617ed

The change adds keyboard activation and focus handling for tree rows and chevrons. A bounded merge-readiness risk remains: refreshing the tree may fail to restore keyboard focus if focus detection does not account for the component’s active shadow-root element; this should receive explicit owner follow-up. The PR is otherwise mergeable with that awareness.

Pre-merge checks: Passed 5
Passed Passed checks: 5 passed
Check name Status Explanation
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly summarizes the main changes: keyboard activation for tree-item node selection and expand/collapse behavior. It is specific and related to the changeset.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ix-4342-tree

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.

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

Copy link
Copy Markdown
Contributor

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 enhances the tree-item component's accessibility and keyboard navigation by making the chevron icon and tree node container focusable and interactive via Space and Enter keys. The review feedback recommends adding an axe-based accessibility test to comply with the Repository Style Guide, adding outline: none to the chevron icon to prevent double focus outlines, stopping event propagation in the container's keydown handler, and adding role="button" to the tree node container to properly identify it as interactive to assistive technologies.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@1307-Dev
1307-Dev marked this pull request as ready for review July 28, 2026 07:38

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 6

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/core/src/components/tree-item/tree-item.scss`:
- Line 37: Update the focus-visible mixin invocations in the tree-item styles,
including both occurrences near the referenced lines, to use argumentless mixin
syntax without parentheses. Preserve the existing focus-visible styling while
removing only the unnecessary parentheses so Stylelint passes.

In `@packages/core/src/components/tree-item/tree-item.tsx`:
- Around line 89-96: Update the chevron control in the tree-item component to
expose its current expansion state with aria-expanded based on
this.context?.isExpanded, and expose disabled state with aria-disabled based on
isDisabled. Preserve the existing role, label, and tabIndex behavior while
applying these attributes to both referenced control locations.
- Around line 105-131: Add coverage for the ix-tree-item keyboard interaction:
create axe-based component tests covering Enter and Space activation, disabled
behavior, focus-visible states, and focus preservation across refreshes. Update
the applicable framework accessibility tests and Storybook tree stories, and add
a changeset documenting the accessibility/behavior change unless it is
explicitly justified as internal-only.

In `@packages/core/src/components/tree/tree.tsx`:
- Around line 364-369: Update the focus handling around focusInfo.target in the
tree component so that when the requested ix-icon chevron is absent, focus falls
back to the tree-node-container element. Preserve the existing chevron focus
behavior when the icon exists, and keep the current container fallback for
non-chevron targets.
- Around line 361-363: Update the selector construction in the tree refresh
logic around treeItem to escape focusInfo.nodeId with the appropriate CSS
selector escaping mechanism before interpolation, ensuring IDs containing quotes
or other CSS-special characters produce a valid querySelector selector.
- Around line 321-332: Update the tree focus-preservation logic around
getTreeNodeId to begin at this.hostElement.shadowRoot.activeElement, then
recursively descend through nested shadowRoot.activeElement values until
locating the element carrying data-tree-node-id, including inside embedded
ix-test-item components. Preserve the existing shadow icon handling and add a
regression test covering refresh/focus restoration across nested shadow roots.
🪄 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: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: be709f47-005e-495c-9acd-bdb4bf7b8fbf

📥 Commits

Reviewing files that changed from the base of the PR and between 70e1c5c and 1a03e9b.

📒 Files selected for processing (3)
  • packages/core/src/components/tree-item/tree-item.scss
  • packages/core/src/components/tree-item/tree-item.tsx
  • packages/core/src/components/tree/tree.tsx

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

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 current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/core/src/components/tree/test/tree.ct.ts`:
- Line 96: Remove the focused-test modifier from the regressionTest declarations
at the “collapsed” case and the additionally identified tests, restoring each to
regressionTest so the full tree test coverage runs.
🪄 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: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 0e7312ae-a3d3-4eb3-8250-d04ef7e3f649

📥 Commits

Reviewing files that changed from the base of the PR and between 1a03e9b and b250d4e.

📒 Files selected for processing (5)
  • .changeset/keyboard-tree-item-a11y.md
  • packages/core/src/components/tree-item/tree-item.scss
  • packages/core/src/components/tree-item/tree-item.tsx
  • packages/core/src/components/tree/test/tree.ct.ts
  • packages/core/src/components/tree/tree.tsx

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

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 current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/core/src/components/tree/test/tree.ct.ts`:
- Line 912: Add a regression test alongside the existing tree focus-restoration
tests in regressionTest to focus a node’s chevron, call refreshTree(), and
assert that the same chevron remains focused, covering the separate target ===
'chevron' restoration path in the tree component.
🪄 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: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: a511ab3a-c072-4b20-9e61-469930ea8e89

📥 Commits

Reviewing files that changed from the base of the PR and between b250d4e and d74ef50.

📒 Files selected for processing (1)
  • packages/core/src/components/tree/test/tree.ct.ts

@1307-Dev
1307-Dev requested a review from a team as a code owner August 19, 2026 03:58
@1307-Dev
1307-Dev requested a review from danielleroux August 19, 2026 03:58
@sonarqubecloud

Copy link
Copy Markdown

@JonaMaiss JonaMaiss self-assigned this Oct 7, 2026
@JonaMaiss JonaMaiss added this to the 6.0.0 milestone Oct 7, 2026
@JonaMaiss
JonaMaiss requested a review from a team as a code owner October 7, 2026 08:04
@JonaMaiss
JonaMaiss requested a review from lzeiml October 15, 2026 08:18
@lzeiml
lzeiml enabled auto-merge October 19, 2026 11:25
lzeiml
lzeiml previously approved these changes Oct 19, 2026
@sonarqubecloud

Copy link
Copy Markdown

@lzeiml
lzeiml merged commit 1accd43 into main Oct 21, 2026
25 checks passed
@lzeiml
lzeiml deleted the ix-4342-tree branch October 21, 2026 08:54
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.

6 participants