Skip to content

Commit b85c76e

Browse files
authored
[OGUI-561] Browse object tree with key arrows (#3256)
* Add keyboard arrow navigation for object tree
1 parent a8e55f9 commit b85c76e

File tree

9 files changed

+533
-91
lines changed

9 files changed

+533
-91
lines changed

QualityControl/public/Model.js

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,17 +139,36 @@ export default class Model extends Observable {
139139
*/
140140
handleKeyboardDown(e) {
141141
// Console.log(`e.keyCode=${e.keyCode}, e.metaKey=${e.metaKey}, e.ctrlKey=${e.ctrlKey}, e.altKey=${e.altKey}`);
142-
const code = e.keyCode;
143-
142+
const { key } = e;
144143
// Delete key + layout page + object select => delete this object
145-
if (code === 8 &&
144+
if (key === 'Delete' &&
146145
this.router.params.page === 'layoutShow' &&
147146
this.layout.editEnabled &&
148147
this.layout.editingTabObject) {
149148
this.layout.deleteTabObject(this.layout.editingTabObject);
150-
} else if (code === 27 && this.isImportVisible) {
149+
} else if (key === 'Escape' && this.isImportVisible) {
151150
this.layout.resetImport();
152151
}
152+
if (
153+
this.router.params.page === 'objectTree' &&
154+
(
155+
key === 'ArrowUp' ||
156+
key === 'ArrowDown' ||
157+
key === 'Enter' ||
158+
key === 'ArrowLeft' ||
159+
key === 'ArrowRight'
160+
)
161+
) {
162+
e.preventDefault(); // Prevent scrolling the page
163+
const searchActive = Boolean(this.object.searchInput?.trim());
164+
if (searchActive) {
165+
// Search navigation
166+
this.object.handleKeyboardNavigationSearchResults(key);
167+
} else {
168+
// Tree navigation
169+
this.object.tree.handleKeyboardNavigation(key, (selectedObject) => this.object.select(selectedObject));
170+
}
171+
}
153172
}
154173

155174
/**
@@ -288,7 +307,7 @@ export default class Model extends Observable {
288307

289308
/**
290309
* Clear URL parameters and redirect to a certain page
291-
* @param {*} pageName - name of the page to be redirected to
310+
* @param {string} pageName - name of the page to be redirected to
292311
* @returns {undefined}
293312
*/
294313
clearURL(pageName) {

QualityControl/public/app.css

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
.object-selectable { cursor: pointer; text-decoration: none; }
2727
.object-selectable:hover { cursor: pointer; background-color: var(--color-gray-dark) !important; color: var(--color-gray-lighter); }
2828

29+
.focused-node>th, .focused-node>td { background-color: var(--color-gray-dark); color: var(--color-white); }
30+
2931
.layout-selectable { border: 0.0em solid var(--color-primary); transition: border 0.1s; }
3032
.layout-selected { border: 0.3em solid var(--color-primary); }
3133
.layout-edit-layer { cursor: move; opacity: 0; }
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/**
2+
* @license
3+
* Copyright 2019-2020 CERN and copyright holders of ALICE O2.
4+
* See http://alice-o2.web.cern.ch/copyright for details of the copyright holders.
5+
* All rights not expressly granted are reserved.
6+
*
7+
* This software is distributed under the terms of the GNU General Public
8+
* License v3 (GPL Version 3), copied verbatim in the file "COPYING".
9+
*
10+
* In applying this license CERN does not waive the privileges and immunities
11+
* granted to it by virtue of its status as an Intergovernmental Organization
12+
* or submit itself to any jurisdiction.
13+
*/
14+
15+
export const OBJECT_LIST_SIDE_ROW_HEIGHT = 29.4;

QualityControl/public/common/enums/storageKeys.enum.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@
2020
export const StorageKeysEnum = Object.freeze({
2121
OBJECT_VIEW_LEFT_PANEL_WIDTH: 'object-view-left-panel-width',
2222
OBJECT_VIEW_INFO_VISIBILITY_SETTING: 'object-view-info-visibility-setting',
23+
OBJECT_TREE_OPEN_BRANCH_STATE: 'object-tree-open-branch-state',
2324
NOTIFICATION_START_RUN_SETTING: 'notification-start-run-setting',
24-
OBJECT_TREE_OPEN_NODES: 'object-tree-open-nodes',
2525
});

0 commit comments

Comments
 (0)