Skip to content

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

Open
1307-Dev wants to merge 9 commits into
mainfrom
ix-4342-tree
Open

feat(core/tree)- Improve keyboard activation for node selection and expand/collapse for tree-item#2665
1307-Dev wants to merge 9 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 both the tree chevron and the tree node container.
    • Added consistent focus-visible styling for keyboard navigation on the node area and expand/collapse toggle.
    • Preserved focus across virtualized tree refreshes to prevent unexpected focus loss.
    • Improved screen-reader announcements with updated expanded/disabled attributes for interactive controls.
  • Tests
    • Added Playwright Axe accessibility checks and keyboard regression tests for expand/select behavior, 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 89d18c9
🔍 Latest deploy log https://app.netlify.com/projects/ix-storybook/deploys/6a699e52973bd30008b44aa6
😎 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: 89d18c9

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

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown

Review Change Stack

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: a7e579a4-6b11-4734-a183-f57e09c66816

📥 Commits

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

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

📝 Walkthrough

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 Hyperlist
  participant TreeItem
  Tree->>Document: Inspect activeElement and shadow DOM
  Tree->>Hyperlist: Refresh virtualized list
  Hyperlist-->>Tree: Return refreshed tree DOM
  Tree->>TreeItem: Focus matching icon or node container
Loading

Suggested reviewers: danielleroux, nuke-ellington

🚥 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 clearly matches the main change: improved keyboard activation for tree item selection and expand/collapse behavior.
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.
✨ 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.

Comment thread packages/core/src/components/tree-item/tree-item.tsx
Comment thread packages/core/src/components/tree-item/tree-item.scss
Comment thread packages/core/src/components/tree-item/tree-item.tsx
Comment thread packages/core/src/components/tree-item/tree-item.tsx
@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

Comment thread packages/core/src/components/tree-item/tree-item.scss Outdated
Comment thread packages/core/src/components/tree-item/tree-item.tsx
Comment thread packages/core/src/components/tree-item/tree-item.tsx
Comment thread packages/core/src/components/tree/tree.tsx
Comment thread packages/core/src/components/tree/tree.tsx
Comment thread 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

Comment thread packages/core/src/components/tree/test/tree.ct.ts Outdated

@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

}
);

regressionTest(

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Cover chevron focus restoration after refresh.

This regression test verifies focus preservation for .tree-node-container, but packages/core/src/components/tree/tree.tsx has a separate target === 'chevron' restoration path. Add a corresponding test that focuses the chevron, calls refreshTree(), and asserts the chevron remains focused.

🤖 Prompt for 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.

In `@packages/core/src/components/tree/test/tree.ct.ts` at 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.

@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.

1 participant