From 27e720f23af43fbe16f4a3b83a3886ed7a33158d Mon Sep 17 00:00:00 2001 From: Pavel Feldman Date: Mon, 19 Apr 2021 11:09:50 -1000 Subject: [PATCH] feat(tracing): keyboard navigate lists (#6224) --- src/web/traceViewer/ui/actionList.css | 17 +++++++++-------- src/web/traceViewer/ui/actionList.tsx | 22 +++++++++++++++++++++- src/web/traceViewer/ui/snapshotTab.css | 21 ++++++++++++++++----- src/web/traceViewer/ui/snapshotTab.tsx | 12 ++++++++++-- src/web/traceViewer/ui/timeline.css | 6 +++++- 5 files changed, 61 insertions(+), 17 deletions(-) diff --git a/src/web/traceViewer/ui/actionList.css b/src/web/traceViewer/ui/actionList.css index 6d3993aef3..a98a8a2404 100644 --- a/src/web/traceViewer/ui/actionList.css +++ b/src/web/traceViewer/ui/actionList.css @@ -22,6 +22,7 @@ user-select: none; color: #555; overflow: auto; + outline: none; } .action-entry { @@ -32,19 +33,19 @@ white-space: nowrap; line-height: 28px; padding-left: 3px; - border-left: 3px solid transparent; -} - -.action-entry:hover, .action-entry.selected { - color: #333; } .action-entry.selected { - border-left: 3px solid #666; + color: white; + background-color: var(--gray); } -.action-entry.selected:focus { - border-color: var(--orange); +.action-list:focus .action-entry.selected { + background-color: var(--blue); +} + +.action-entry.selected > div { + color: white; } .action-title { diff --git a/src/web/traceViewer/ui/actionList.tsx b/src/web/traceViewer/ui/actionList.tsx index 9d0921be50..0105d9d226 100644 --- a/src/web/traceViewer/ui/actionList.tsx +++ b/src/web/traceViewer/ui/actionList.tsx @@ -33,7 +33,27 @@ export const ActionList: React.FC = ({ onSelected = () => {}, onHighlighted = () => {}, }) => { - return
{actions.map(actionEntry => { + return
{ + if (event.key !== 'ArrowDown' && event.key !== 'ArrowUp') + return; + const index = selectedAction ? actions.indexOf(selectedAction) : -1; + if (event.key === 'ArrowDown') { + if (index === -1) + onSelected(actions[0]); + else + onSelected(actions[Math.min(index + 1, actions.length - 1)]); + } + if (event.key === 'ArrowUp') { + if (index === -1) + onSelected(actions[actions.length - 1]); + else + onSelected(actions[Math.max(index - 1, 0)]); + } + }} + >{actions.map((actionEntry, index) => { const { metadata, actionId } = actionEntry; return
-
+ return
{ + if (event.key === 'ArrowDown') + setSnapshotIndex(Math.min(snapshotIndex + 1, snapshots.length - 1)); + if (event.key === 'ArrowUp') + setSnapshotIndex(Math.max(snapshotIndex - 1, 0)); + }} + >
{snapshots.map((snapshot, index) => { return