diff --git a/chrome/content/zotero/preferences/preferences_sync.js b/chrome/content/zotero/preferences/preferences_sync.js
index fd379f6b6..ba0da06e0 100644
--- a/chrome/content/zotero/preferences/preferences_sync.js
+++ b/chrome/content/zotero/preferences/preferences_sync.js
@@ -85,7 +85,6 @@ Zotero_Preferences.Sync = {
credentialsKeyPress: function (event) {
var username = document.getElementById('sync-username-textbox');
- username.value = username.value.trim();
var password = document.getElementById('sync-password');
var syncAuthButton = document.getElementById('sync-auth-button');
@@ -103,9 +102,22 @@ Zotero_Preferences.Sync = {
Zotero_Preferences.Sync.linkAccount(event);
}
},
-
-
+
+
+ trimUsername: function () {
+ var tb = document.getElementById('sync-username-textbox');
+ var username = tb.value;
+ var trimmed = username.trim();
+ if (username != trimmed) {
+ tb.value = trimmed;
+ // Setting .value alone doesn't seem to cause the pref to sync, so set it manually
+ Zotero.Prefs.set('sync.server.username', trimmed);
+ }
+ },
+
+
linkAccount: Zotero.Promise.coroutine(function* (event) {
+ this.trimUsername();
var username = document.getElementById('sync-username-textbox').value;
var password = document.getElementById('sync-password').value;
diff --git a/chrome/content/zotero/preferences/preferences_sync.xul b/chrome/content/zotero/preferences/preferences_sync.xul
index 339528519..cafb41ee0 100644
--- a/chrome/content/zotero/preferences/preferences_sync.xul
+++ b/chrome/content/zotero/preferences/preferences_sync.xul
@@ -67,6 +67,7 @@