HTML tree: Add tree.focus()
And fix shortcut key for selecting library
This commit is contained in:
parent
dea4a47b69
commit
8d3adb6f46
2 changed files with 13 additions and 2 deletions
|
@ -46,7 +46,7 @@ var LibraryTree = class LibraryTree extends React.Component {
|
||||||
get window() {
|
get window() {
|
||||||
return this._ownerDocument.defaultView;
|
return this._ownerDocument.defaultView;
|
||||||
}
|
}
|
||||||
|
|
||||||
get selection() {
|
get selection() {
|
||||||
return this.tree ? this.tree.selection : TreeSelectionStub;
|
return this.tree ? this.tree.selection : TreeSelectionStub;
|
||||||
}
|
}
|
||||||
|
@ -71,6 +71,17 @@ var LibraryTree = class LibraryTree extends React.Component {
|
||||||
if (this.type == 'item') Zotero.Prefs.clear('lastViewedFolder');
|
if (this.type == 'item') Zotero.Prefs.clear('lastViewedFolder');
|
||||||
Zotero.crash();
|
Zotero.crash();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
focus() {
|
||||||
|
this.tree.focus();
|
||||||
|
// If no rows selected, select first visible row
|
||||||
|
if (!this.tree.selection.count) {
|
||||||
|
this.tree.selection.select(
|
||||||
|
// TODO: Return -1 when no rows, and skip selection here
|
||||||
|
this.tree._jsWindow.getFirstVisibleRow()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
getParentIndex = (index) => {
|
getParentIndex = (index) => {
|
||||||
var thisLevel = this.getLevel(index);
|
var thisLevel = this.getLevel(index);
|
||||||
|
|
|
@ -759,7 +759,7 @@ var ZoteroPane = new function()
|
||||||
try {
|
try {
|
||||||
switch (command) {
|
switch (command) {
|
||||||
case 'library':
|
case 'library':
|
||||||
document.getElementById('zotero-collections-tree').focus();
|
this.itemsView.focus();
|
||||||
break;
|
break;
|
||||||
case 'quicksearch':
|
case 'quicksearch':
|
||||||
document.getElementById('zotero-tb-search').select();
|
document.getElementById('zotero-tb-search').select();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue