commit 1e0674cf7cd5a229f763d95abd257b1a4cf772ca
parent 5d85bffc9cab52232e4c7d843e93ebb7e3f00445
Author: Dan Stillman <dstillman@zotero.org>
Date: Thu, 21 Nov 2013 19:52:13 -0500
Fix some bugs adding items to various views
- Refresh Unfiled Items view when items are added
- Fix brief freeze ("too much recursion") adding an item to a search
where the new item doesn't appear. Now, select the library root
instead if a manually added item doesn't appear in the current view.
- Fix immediate closing of title field when adding an item to a
collection rather than the library root
Diffstat:
2 files changed, 13 insertions(+), 10 deletions(-)
diff --git a/chrome/content/zotero/xpcom/itemTreeView.js b/chrome/content/zotero/xpcom/itemTreeView.js
@@ -317,6 +317,8 @@ Zotero.ItemTreeView.prototype._refreshGenerator = function()
var usiDisabled = Zotero.UnresponsiveScriptIndicator.disable();
+ Zotero.ItemGroupCache.clear();
+
this._searchMode = this._itemGroup.isSearchMode();
if (!this.selection.selectEventsSuppressed) {
@@ -593,8 +595,6 @@ Zotero.ItemTreeView.prototype.notify = function(action, type, ids, extraData)
// If trash or saved search, just re-run search
if (itemGroup.isTrash() || itemGroup.isSearch())
{
- Zotero.ItemGroupCache.clear();
-
// Clear item type icons
var items = Zotero.Items.get(ids);
for (let i=0; i<items.length; i++) {
@@ -711,16 +711,15 @@ Zotero.ItemTreeView.prototype.notify = function(action, type, ids, extraData)
}
else if(action == 'add')
{
- // If saved search or trash, just re-run search
- if (itemGroup.isSearch() || itemGroup.isTrash()) {
+ // In some modes, just re-run search
+ if (itemGroup.isSearch() || itemGroup.isTrash() || itemGroup.isUnfiled()) {
this.refresh();
madeChanges = true;
sort = true;
}
- // If not a quicksearch and not background window saved search,
- // process new items manually
- else if (quicksearch && quicksearch.value == '')
+ // If not a quicksearch, process new items manually
+ else if (!quicksearch || quicksearch.value == '')
{
var items = Zotero.Items.get(ids);
for each(var item in items) {
@@ -740,7 +739,7 @@ Zotero.ItemTreeView.prototype.notify = function(action, type, ids, extraData)
sort = (items.length == 1) ? items[0].id : true;
}
}
- // Otherwise re-run the search, which refreshes the item list
+ // Otherwise re-run the quick search, which refreshes the item list
else
{
// For item adds, clear the quicksearch, unless all the new items
@@ -1802,7 +1801,7 @@ Zotero.ItemTreeView.prototype.selectItem = function(id, expand, noRecurse)
// Don't change selection if UI updates are disabled (e.g., during sync)
if (Zotero.suppressUIUpdates) {
Zotero.debug("Sync is running; not selecting item");
- return;
+ return false;
}
// If no row map, we're probably in the process of switching collections,
diff --git a/chrome/content/zotero/zoteroPane.js b/chrome/content/zotero/zoteroPane.js
@@ -773,7 +773,11 @@ var ZoteroPane = new function()
if (manual) {
// Focus the title field
- document.getElementById('zotero-editpane-item-box').focusFirstField();
+ if (this.selectItem(itemID)) {
+ setTimeout(function () {
+ document.getElementById('zotero-editpane-item-box').focusFirstField();
+ }, 0);
+ }
// Update most-recently-used list for New Item menu
this.addItemTypeToNewItemTypeMRU(typeID);