Skip to content

fix: allow TreeView ArrowUp/ArrowDown navigation when item is focused but not selected#510

Merged
willeastcott merged 1 commit into
mainfrom
fix/treeview-arrow-key-navigation
Feb 26, 2026
Merged

fix: allow TreeView ArrowUp/ArrowDown navigation when item is focused but not selected#510
willeastcott merged 1 commit into
mainfrom
fix/treeview-arrow-key-navigation

Conversation

@willeastcott

@willeastcott willeastcott commented Feb 26, 2026

Copy link
Copy Markdown
Contributor

Summary

  • ArrowUp/ArrowDown in TreeView._onChildKeyDown were guarded by if (this._selectedItems.length) but ArrowLeft/ArrowRight were not
  • This caused ArrowUp/ArrowDown to fail when a TreeViewItem had focus but was not in _selectedItems (e.g. when an external consumer deselects the item while keeping it focused)
  • The item parameter is always the focused TreeViewItem that generated the keydown event, making it a valid navigation starting point regardless of selection state

Test plan

  • In the PlayCanvas Editor, click a folder in the Assets panel TreeView
  • Verify ArrowUp/ArrowDown now navigate between folders
  • Verify ArrowLeft/ArrowRight continue to work (collapse/expand and parent/child navigation)
  • Verify Shift+ArrowUp/Down multi-select still works

Made with Cursor

@willeastcott willeastcott requested a review from Copilot February 26, 2026 23:26
@willeastcott willeastcott self-assigned this Feb 26, 2026
@willeastcott willeastcott added the bug Something isn't working label Feb 26, 2026
@willeastcott willeastcott merged commit 9ee3f90 into main Feb 26, 2026
7 checks passed
@willeastcott willeastcott deleted the fix/treeview-arrow-key-navigation branch February 26, 2026 23:27

Copilot AI 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.

Pull request overview

This PR fixes a keyboard navigation bug in the TreeView component where ArrowUp/ArrowDown keys failed to work when a TreeViewItem had focus but was not selected. The fix removes unnecessary selection state checks that were preventing navigation, making ArrowUp/ArrowDown behavior consistent with ArrowLeft/ArrowRight.

Changes:

  • Removed if (this._selectedItems.length) guard from ArrowUp/ArrowDown handlers
  • Navigation now works based on focused item regardless of selection state
  • ArrowUp/ArrowDown behavior now matches ArrowLeft/ArrowRight pattern

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants