-
Notifications
You must be signed in to change notification settings - Fork 601
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix keyboarding behavior for right and left arrow keys in Tree View #5899
Changes from all commits
50a2afb
f169ace
22ec523
5907851
247ab42
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"type": "patch", | ||
"comment": "fix keyboarding behavior for right and left arrow keys in Tree View", | ||
"packageName": "@microsoft/fast-foundation", | ||
"email": "chhol@microsoft.com", | ||
"dependentChangeType": "patch" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -147,16 +147,32 @@ export class TreeView extends FoundationElement { | |
case keyArrowLeft: | ||
if (e.target && this.isFocusableElement(e.target as HTMLElement)) { | ||
const item = e.target as HTMLElement; | ||
if (item instanceof TreeItem && item.childItemLength() > 0) { | ||
|
||
if ( | ||
item instanceof TreeItem && | ||
item.childItemLength() > 0 && | ||
item.expanded | ||
) { | ||
item.expanded = false; | ||
} else if ( | ||
item instanceof TreeItem && | ||
item.parentElement instanceof TreeItem | ||
) { | ||
TreeItem.focusItem(item.parentElement); | ||
} | ||
Comment on lines
+157
to
162
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Left arrow on either a child node or a closed node moves focus to its parent (if one exists). |
||
} | ||
return false; | ||
case keyArrowRight: | ||
if (e.target && this.isFocusableElement(e.target as HTMLElement)) { | ||
const item = e.target as HTMLElement; | ||
if (item instanceof TreeItem && item.childItemLength() > 0) { | ||
if ( | ||
item instanceof TreeItem && | ||
item.childItemLength() > 0 && | ||
!item.expanded | ||
) { | ||
item.expanded = true; | ||
Comment on lines
+168
to
173
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right arrow on a closed node expands the node without moving focus. |
||
} else if (item instanceof TreeItem && item.childItemLength() > 0) { | ||
this.focusNextNode(1, e.target as TreeItem); | ||
Comment on lines
+174
to
+175
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right arrow on expanded parent node focus its first child node. |
||
} | ||
} | ||
return; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left arrow on an open parent node closes the node without moving focus.