Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

feat(tracing): keyboard navigate lists (#6224)

Pavel Feldman27e720f23af4
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 {
+ color: white;
+ background-color: var(--gray);
}
-.action-entry.selected {
- border-left: 3px solid #666;
+.action-list:focus .action-entry.selected {
+ background-color: var(--blue);
}
-.action-entry.selected:focus {
- border-color: var(--orange);
+.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<ActionListProps> = ({
onSelected = () => {},
onHighlighted = () => {},
}) => {
- return <div className='action-list'>{actions.map(actionEntry => {
+ return <div
+ className='action-list'
+ tabIndex={0}
+ onKeyDown={event => {
+ 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 <div
className={'action-entry' + (actionEntry === selectedAction ? ' selected' : '')}
diff --git a/src/web/traceViewer/ui/snapshotTab.css b/src/web/traceViewer/ui/snapshotTab.css
index 6d2760e761..fbe10b936d 100644
--- a/src/web/traceViewer/ui/snapshotTab.css
+++ b/src/web/traceViewer/ui/snapshotTab.css
@@ -17,23 +17,29 @@
.snapshot-tab {
display: flex;
flex: auto;
- flex-direction: column;
align-items: stretch;
+ outline: none;
+ padding-right: 60px;
}
.snapshot-controls {
- flex: 0 0 24px;
+ flex: 0 0 60px;
display: flex;
- flex-direction: row;
+ flex-direction: column;
align-items: center;
- padding: 10px 4px 0 0;
+ padding: 5px 0 0 5px;
}
.snapshot-toggle {
+ margin-top: 4px;
padding: 4px 8px;
cursor: pointer;
border-radius: 20px;
margin-left: 4px;
+ width: 60px;
+ display: flex;
+ align-items: center;
+ justify-content: center;
}
.snapshot-toggle:hover {
@@ -41,7 +47,12 @@
}
.snapshot-toggle.toggled {
- background: var(--inactive-focus-ring);
+ background: var(--gray);
+ color: white;
+}
+
+.snapshot-tab:focus .snapshot-toggle.toggled {
+ background: var(--blue);
}
.snapshot-wrapper {
diff --git a/src/web/traceViewer/ui/snapshotTab.tsx b/src/web/traceViewer/ui/snapshotTab.tsx
index 8b361a93c5..26e92712a1 100644
--- a/src/web/traceViewer/ui/snapshotTab.tsx
+++ b/src/web/traceViewer/ui/snapshotTab.tsx
@@ -56,8 +56,16 @@ export const SnapshotTab: React.FunctionComponent<{
width: snapshotSize.width * scale,
height: snapshotSize.height * scale,
};
- return <div className='snapshot-tab'>
- <div className='snapshot-controls'>
+ return <div
+ className='snapshot-tab'
+ tabIndex={0}
+ onKeyDown={event => {
+ if (event.key === 'ArrowDown')
+ setSnapshotIndex(Math.min(snapshotIndex + 1, snapshots.length - 1));
+ if (event.key === 'ArrowUp')
+ setSnapshotIndex(Math.max(snapshotIndex - 1, 0));
+ }}
+ ><div className='snapshot-controls'>
{snapshots.map((snapshot, index) => {
return <div
key={snapshot.title}
diff --git a/src/web/traceViewer/ui/timeline.css b/src/web/traceViewer/ui/timeline.css
index 41cca83897..f36cd409a7 100644
--- a/src/web/traceViewer/ui/timeline.css
+++ b/src/web/traceViewer/ui/timeline.css
@@ -46,10 +46,14 @@
pointer-events: none;
overflow: hidden;
flex: none;
- flex-basis: 30px;
+ height: 30px;
position: relative;
}
+.timeline-lane.timeline-labels {
+ height: 20px;
+}
+
.timeline-grid {
position: absolute;
top: 0;