diff --git a/chrome/content/zotero/components/virtualized-table.jsx b/chrome/content/zotero/components/virtualized-table.jsx index eb55b4cddf..debfa38a8f 100644 --- a/chrome/content/zotero/components/virtualized-table.jsx +++ b/chrome/content/zotero/components/virtualized-table.jsx @@ -358,6 +358,7 @@ class VirtualizedTable extends React.Component { // If you want to perform custom key handling it should be in this function // if it returns false then virtualized-table's own key handler won't run onKeyDown: () => true, + onKeyUp: noop, onDragOver: noop, onDrop: noop, @@ -420,6 +421,7 @@ class VirtualizedTable extends React.Component { // If you want to perform custom key handling it should be in this function // if it returns false then virtualized-table's own key handler won't run onKeyDown: PropTypes.func, + onKeyUp: PropTypes.func, onDragOver: PropTypes.func, onDrop: PropTypes.func, @@ -1145,6 +1147,7 @@ class VirtualizedTable extends React.Component { } let props = { onKeyDown: this._onKeyDown, + onKeyUp: e => this.props.onKeyUp && this.props.onKeyUp(e), onDragOver: this._onDragOver, onDrop: e => this.props.onDrop && this.props.onDrop(e), onFocus: e => this.props.onFocus && this.props.onFocus(e), diff --git a/chrome/content/zotero/itemTree.jsx b/chrome/content/zotero/itemTree.jsx index 37ccebf24b..f38f8bb8b5 100644 --- a/chrome/content/zotero/itemTree.jsx +++ b/chrome/content/zotero/itemTree.jsx @@ -825,15 +825,6 @@ var ItemTree = class ItemTree extends LibraryTree { } } - handleFocus = (event) => { - if (Zotero.locked) { - return false; - } - if (this.selection.count == 0) { - this.selection.select(this.selection.pivot); - } - } - handleActivate = (event, indices) => { // Ignore double-clicks in duplicates view on everything except attachments let items = indices.map(index => this.getRow(index).ref); @@ -905,6 +896,15 @@ var ItemTree = class ItemTree extends LibraryTree { } return true; } + + /** + * Select the first row when the tree is focused by the keyboard. + */ + handleKeyUp = (event) => { + if (!Zotero.locked && event.code === 'Tab' && this.selection.count == 0) { + this.selection.select(this.selection.pivot); + } + }; render() { const itemsPaneMessageHTML = this._itemsPaneMessage || this.props.emptyMessage; @@ -969,8 +969,8 @@ var ItemTree = class ItemTree extends LibraryTree { onDragOver: e => this.props.dragAndDrop && this.onDragOver(e, -1), onDrop: e => this.props.dragAndDrop && this.onDrop(e, -1), onKeyDown: this.handleKeyDown, + onKeyUp: this.handleKeyUp, onActivate: this.handleActivate, - onFocus: this.handleFocus, onItemContextMenu: (...args) => this.props.onContextMenu(...args),