Skip to content

feat: add pressedArrow property to TreeView#517

Merged
willeastcott merged 1 commit into
mainfrom
feat/treeview-pressed-arrow
Mar 3, 2026
Merged

feat: add pressedArrow property to TreeView#517
willeastcott merged 1 commit into
mainfrom
feat/treeview-pressed-arrow

Conversation

@willeastcott

Copy link
Copy Markdown
Contributor

Summary

  • Add pressedArrow property to TreeView, following the same pattern as pressedCtrl and pressedShift
  • Allows consumers to distinguish arrow key navigation from mouse click selection in select/deselect event handlers

Motivation

The PlayCanvas Editor's Assets panel has a folder TreeView where clicking a folder once navigates into it, and clicking it again shows it in the Inspector. When using arrow keys to navigate between folders, the Inspector should update — but the select event provides no way to distinguish keyboard navigation from mouse clicks.

This adds the missing piece: pressedArrow is true during select/deselect events triggered by arrow key navigation in _onChildKeyDown, and false otherwise.

API

treeView.on('select', (item) => {
    if (treeView.pressedArrow) {
        // selection was triggered by arrow key navigation
    }
});

Test plan

  • Verify pressedArrow is true inside select/deselect handlers during arrow key navigation
  • Verify pressedArrow is false inside select/deselect handlers during mouse clicks
  • Verify pressedCtrl and pressedShift behavior is unchanged

@willeastcott willeastcott requested a review from Copilot March 3, 2026 17:42
@willeastcott willeastcott self-assigned this Mar 3, 2026
@willeastcott willeastcott added the enhancement New feature or request label Mar 3, 2026

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

Adds a pressedArrow flag to TreeView so consumers can differentiate arrow-key navigation selection changes from mouse-driven selection in select/deselect handlers (mirroring the existing pressedCtrl/pressedShift pattern).

Changes:

  • Introduces internal _pressedArrow state and exposes it via get pressedArrow().
  • Sets _pressedArrow true during arrow-key navigation handling in _onChildKeyDown, then resets it after handling.

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

Comment thread src/components/TreeView/index.ts Outdated
Expose whether a selection change was triggered by arrow key navigation, following the same pattern as pressedCtrl and pressedShift.

Made-with: Cursor

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

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.


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

@willeastcott willeastcott merged commit 45e2f85 into main Mar 3, 2026
9 checks passed
@willeastcott willeastcott deleted the feat/treeview-pressed-arrow branch March 3, 2026 17:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants