minor collection search improvements
- always scroll to selected row on empty filter - fixed a bug that would interfere with focusing on the selected collection on Enter if there are capital letters in the filter field
This commit is contained in:
parent
7d68f75d03
commit
741ed9b98c
2 changed files with 12 additions and 7 deletions
|
@ -2372,14 +2372,15 @@ var CollectionTree = class CollectionTree extends LibraryTree {
|
|||
* Set collection filter and refresh collectionTree to only include
|
||||
* rows that match the filter. Rows that do not match the filter but have children that do
|
||||
* are displayed as context rows. All relevant rows are toggled open. Selection is kept
|
||||
* on the currently selected row if any.
|
||||
* on the currently selected row if any. If the filter is emptied out, the currently selected
|
||||
* row is scrolled to. Otherwise, scroll to the very top.
|
||||
* @param {String} filterText - Text that rows have to contain to match the filter
|
||||
* @param {Bool} scrollToSelected - Allow scrolling to the currently selected row.
|
||||
*/
|
||||
async setFilter(filterText, scrollToSelected) {
|
||||
async setFilter(filterText) {
|
||||
this._filter = filterText.toLowerCase();
|
||||
let currentRow = this.getRow(this.selection.focused) || this._hiddenFocusedRow;
|
||||
let currentRowDisplayed = currentRow && this._includedInTree(currentRow.ref);
|
||||
let scrollToSelected = filterText.length == 0;
|
||||
// If current row does not match any filters, it'll be hidden, so clear selection
|
||||
if (!currentRowDisplayed) {
|
||||
this.selection.clearSelection();
|
||||
|
@ -2410,6 +2411,11 @@ var CollectionTree = class CollectionTree extends LibraryTree {
|
|||
}
|
||||
}
|
||||
}
|
||||
// If the selected collection is not scrolled to, scroll to the very top
|
||||
if (!scrollToSelected) {
|
||||
let collectionTable = document.getElementById("collection-tree").firstElementChild;
|
||||
collectionTable.scrollTop = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -2439,7 +2445,7 @@ var CollectionTree = class CollectionTree extends LibraryTree {
|
|||
}
|
||||
|
||||
filterEquals(filterValue) {
|
||||
return filterValue === this._filter;
|
||||
return filterValue.toLowerCase() === this._filter;
|
||||
}
|
||||
|
||||
_isFilterEmpty() {
|
||||
|
|
|
@ -296,7 +296,7 @@ var ZoteroPane = new function()
|
|||
// Clear the search field
|
||||
if (collectionsSearchField.value.length) {
|
||||
collectionsSearchField.value = '';
|
||||
ZoteroPane.collectionsView.setFilter("", true);
|
||||
ZoteroPane.collectionsView.setFilter("");
|
||||
if (!removeFocus) {
|
||||
return null;
|
||||
}
|
||||
|
@ -2747,8 +2747,7 @@ var ZoteroPane = new function()
|
|||
|
||||
this.handleCollectionSearchInput = function () {
|
||||
let collectionsSearchField = document.getElementById("zotero-collections-search");
|
||||
// Set the filter without scrolling the selected row into the view
|
||||
this.collectionsView.setFilter(collectionsSearchField.value, false);
|
||||
this.collectionsView.setFilter(collectionsSearchField.value);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue