Fix post-save textbox focusing bugs in right-hand pane

Fix a couple cases of lost text field focus after an edit, including
focusing of the Title field after using New Item when a field is already
being edited and has a changed value.

Also, in tests, select My Library and wait for items to load when using
the loadZoteroPane() support function. We could add a parameter to skip
that or move it to a separate function, but the code to detect it is a
bit convoluted and it's a prerequisite for many tests, so it's handy to
have a function for it.
This commit is contained in:
Dan Stillman 2015-05-04 02:00:52 -04:00
parent 590649fd49
commit 8fec5ace3a
7 changed files with 103 additions and 63 deletions

View file

@ -32,20 +32,30 @@ function loadBrowserWindow() {
}
/**
* Loads a Zotero pane in a new window. Returns the containing window.
* Loads a Zotero pane in a new window and selects My Library. Returns the containing window.
*/
function loadZoteroPane() {
return loadBrowserWindow().then(function(win) {
win.ZoteroOverlay.toggleDisplay(true);
// Hack to wait for pane load to finish. This is the same hack
// we use in ZoteroPane.js, so either it's not good enough
// there or it should be good enough here.
return Zotero.Promise.delay(52).then(function() {
return win;
});
});
}
var loadZoteroPane = Zotero.Promise.coroutine(function* () {
var win = yield loadBrowserWindow();
win.ZoteroOverlay.toggleDisplay(true);
// Hack to wait for pane load to finish. This is the same hack
// we use in ZoteroPane.js, so either it's not good enough
// there or it should be good enough here.
yield Zotero.Promise.delay(52);
var zp = win.ZoteroPane;
var cv = zp.collectionsView;
var resolve1, resolve2;
var promise1 = new Zotero.Promise(() => resolve1 = arguments[0]);
var promise2 = new Zotero.Promise(() => resolve2 = arguments[0]);
cv.addEventListener('load', () => resolve1())
yield promise1;
cv.selection.select(0);
zp.addEventListener('itemsLoaded', () => resolve2());
yield promise2;
return win;
});
/**
* Waits for a window with a specific URL to open. Returns a promise for the window.