From 1d9782549639d7a9ea6f1a84822bac2276ec960e Mon Sep 17 00:00:00 2001 From: Raymond Chao Date: Tue, 3 Jun 2014 16:53:10 +0800 Subject: [PATCH] Refix ZSS-674: edit a cell but do not leave, hit save, changes not saved http://tracker.zkoss.org/browse/ZSS-674 --- zss/src/archive/web/js/zss/DataPanel.js | 10 ++++++---- zss/src/archive/web/js/zss/Editbox.js | 9 +++++++-- zss/src/archive/web/js/zss/SSheetCtrl.js | 4 +++- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/zss/src/archive/web/js/zss/DataPanel.js b/zss/src/archive/web/js/zss/DataPanel.js index d7ff8c525..4fe81376a 100644 --- a/zss/src/archive/web/js/zss/DataPanel.js +++ b/zss/src/archive/web/js/zss/DataPanel.js @@ -483,14 +483,16 @@ zss.DataPanel = zk.$extends(zk.Object, { } } else { //when editing formula, always set focus back to editor - var sf = this; - setTimeout(function () { + //var sf = this; + //setTimeout(function () { var info = sheet.editingFormulaInfo; if (info) { info.moveCell = true; - sf.getEditor(info.type).focus(); + //sf.getEditor(info.type).focus(); + // ZSS-674: use flag instead of setTimeout + sheet.shallIgnoreBlur = true; } - }); + //}); } var fzr = sheet.frozenRow, fzc = sheet.frozenCol, diff --git a/zss/src/archive/web/js/zss/Editbox.js b/zss/src/archive/web/js/zss/Editbox.js index a742ea98f..e9d98a930 100644 --- a/zss/src/archive/web/js/zss/Editbox.js +++ b/zss/src/archive/web/js/zss/Editbox.js @@ -64,12 +64,17 @@ Copyright (C) 2007 Potix Corporation. All Rights Reserved. } } - function blurEditor(wgt) { + function blurEditor (wgt) { var sheet = wgt.sheet; if (sheet) { // ZSS-674: stay focused if formulabar's ok/cancel btn was pressed down. if (sheet.shallIgnoreBlur) { - wgt.focus(); + if (!zk.gecko) { + wgt.focus(); + } else { + // 20140603, RaymondChao: firefox needs setTimeout to refocus when blur. + setTimeout(function () {wgt.focus()}); + } sheet.shallIgnoreBlur = false; } else if (sheet.isSwitchingFocus) { // 20140519, RaymondChao: when change focus between editors, spreadsheet could have no focus as below diff --git a/zss/src/archive/web/js/zss/SSheetCtrl.js b/zss/src/archive/web/js/zss/SSheetCtrl.js index b3d6f70a8..cf1c6d200 100644 --- a/zss/src/archive/web/js/zss/SSheetCtrl.js +++ b/zss/src/archive/web/js/zss/SSheetCtrl.js @@ -2352,9 +2352,11 @@ zss.SSheetCtrl = zk.$extends(zk.Widget, { clearTimeout(id); } this._fireCellSelectionId = setTimeout(function () { - self.fire('onCellSelection', {left: left, top: top, right: right, bottom: bottom}); //ZSS 171 + // 20140603, RaymondChao: disable skip before fire onCellSelection to prevent + // editbox skiping to insert cell reference select at the first time self._skipInsertCellRef = false; + self.fire('onCellSelection', {left: left, top: top, right: right, bottom: bottom}); }, 50); }, /**