mirror of
https://github.com/zotero/zotero.git
synced 2026-10-08 03:08:19 +00:00
Fixes #421, Editing a note that doesn't match an active search causes note to be deselected
If an edit causes a note to stop matching the quicksearch, clear the search Also: - Select text in quicksearch when using shortcut key instead of just focusing - Fixed strict warning
This commit is contained in:
parent
268aad212b
commit
eba6d8403b
2 changed files with 24 additions and 11 deletions
|
|
@ -223,7 +223,7 @@ var ZoteroPane = new function()
|
|||
collectionsView.selection.select(0);
|
||||
break;
|
||||
case 'quicksearch':
|
||||
document.getElementById('zotero-tb-search').focus();
|
||||
document.getElementById('zotero-tb-search').select();
|
||||
break;
|
||||
case 'newItem':
|
||||
newItem(2); // book
|
||||
|
|
@ -330,7 +330,7 @@ var ZoteroPane = new function()
|
|||
|
||||
function getTagSelection(){
|
||||
var tagSelector = document.getElementById('zotero-tag-selector');
|
||||
return tagSelector.selection;
|
||||
return tagSelector.selection ? tagSelector.selection : {};
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -164,7 +164,7 @@ Zotero.ItemTreeView.prototype.notify = function(action, type, ids)
|
|||
}
|
||||
|
||||
}
|
||||
else if(action == 'modify') //must check for null because it could legitimately be 0
|
||||
else if (action == 'modify')
|
||||
{
|
||||
// If no quicksearch, process modifications manually
|
||||
if (quicksearch.value == '')
|
||||
|
|
@ -188,7 +188,6 @@ Zotero.ItemTreeView.prototype.notify = function(action, type, ids)
|
|||
this._hideItem(row);
|
||||
this._treebox.rowCountChanged(row+1, -1)
|
||||
}
|
||||
// If
|
||||
else if (!this.isContainer(row) && this.getParentIndex(row)!=-1
|
||||
&& !this._getItemAtRow(row).ref.getSource())
|
||||
{
|
||||
|
|
@ -228,7 +227,7 @@ Zotero.ItemTreeView.prototype.notify = function(action, type, ids)
|
|||
}
|
||||
else if(action == 'add')
|
||||
{
|
||||
// If saved search, just rerun search
|
||||
// If saved search, just re-run search
|
||||
if (this._itemGroup.isSearch())
|
||||
{
|
||||
this.refresh();
|
||||
|
|
@ -257,10 +256,9 @@ Zotero.ItemTreeView.prototype.notify = function(action, type, ids)
|
|||
}
|
||||
}
|
||||
}
|
||||
// Otherwise rerun the search, which refreshes the item list
|
||||
// Otherwise re-run the search, which refreshes the item list
|
||||
else
|
||||
{
|
||||
// If active window, clear search first
|
||||
if (activeWindow)
|
||||
{
|
||||
quicksearch.value = '';
|
||||
|
|
@ -277,8 +275,7 @@ Zotero.ItemTreeView.prototype.notify = function(action, type, ids)
|
|||
this.sort(); //this also refreshes the hash map
|
||||
this._treebox.invalidate();
|
||||
}
|
||||
//else if(action != 'modify') //no need to update this if we modified
|
||||
else //no need to update this if we modified
|
||||
else
|
||||
{
|
||||
this._refreshHashMap();
|
||||
}
|
||||
|
|
@ -292,10 +289,26 @@ Zotero.ItemTreeView.prototype.notify = function(action, type, ids)
|
|||
|
||||
this.selectItem(ids[0]);
|
||||
}
|
||||
// If single item is selected and was modified, reselect
|
||||
// (in case the sort order changed and it went off-screen)
|
||||
// If single item is selected and was modified
|
||||
else if (action == 'modify' && ids.length == 1 &&
|
||||
savedSelection.length == 1 && savedSelection[0] == ids[0]) {
|
||||
// If the item no longer matches the search term, clear the search
|
||||
if (this._itemRowMap[ids[0]] == undefined) {
|
||||
quicksearch.value = '';
|
||||
quicksearch.doCommand();
|
||||
if (this.isSorted())
|
||||
{
|
||||
this.sort();
|
||||
this._treebox.invalidate();
|
||||
}
|
||||
else
|
||||
{
|
||||
this._refreshHashMap();
|
||||
}
|
||||
}
|
||||
|
||||
// Reselect item (in case the sort order changed and the item
|
||||
// went off-screen)
|
||||
this.selectItem(ids[0]);
|
||||
}
|
||||
else
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue