Fix item tree jumping to top on focus without selection (#2347)
This commit is contained in:
parent
b38d7107d8
commit
d82981d601
2 changed files with 13 additions and 10 deletions
|
@ -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),
|
||||
|
|
|
@ -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),
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue