[Libreoffice-commits] online.git: loleaflet/src

Ashod Nakashian (via logerrit) logerrit at kemper.freedesktop.org
Wed Jan 29 17:37:05 UTC 2020


 loleaflet/src/control/Control.LokDialog.js |   13 ++++++-------
 loleaflet/src/map/Map.js                   |   10 ++++++++--
 2 files changed, 14 insertions(+), 9 deletions(-)

New commits:
commit cc9add3208819130d5d7e3f6d873ed67912a7e01
Author:     Ashod Nakashian <ashod.nakashian at collabora.co.uk>
AuthorDate: Wed Jan 29 10:33:19 2020 -0500
Commit:     Aron Budea <aron.budea at collabora.com>
CommitDate: Wed Jan 29 18:36:38 2020 +0100

    leaflet: fix input-bar now showing keyboard on mobile
    
    Change-Id: Ib81822cae342d5e8bc394fc84e43ec681ecffb8f
    Reviewed-on: https://gerrit.libreoffice.org/c/online/+/87693
    Reviewed-by: Aron Budea <aron.budea at collabora.com>
    Tested-by: Aron Budea <aron.budea at collabora.com>

diff --git a/loleaflet/src/control/Control.LokDialog.js b/loleaflet/src/control/Control.LokDialog.js
index 4779f4ed9..6afb2d064 100644
--- a/loleaflet/src/control/Control.LokDialog.js
+++ b/loleaflet/src/control/Control.LokDialog.js
@@ -345,15 +345,15 @@ L.Control.LokDialog = L.Control.extend({
 				$('#' + strId).dialog('option', 'title', e.title);
 			}
 		} else if (e.action === 'cursor_visible') {
-			// cursor_visible means focus has changed.
+			// cursor_visible implies focus has changed, but can
+			// be misleading when it flips back on forth on typing!
 			this._dialogs[e.id].cursorVisible = e.visible === 'true';
 			if (this._dialogs[e.id].cursorVisible) {
 				$('#' + strId + '-cursor').css({display: 'block'});
-				this._map.onFocusDialog(this, e.id);
+				this._map.fire('changefocuswidget', {winId: e.id, dialog: this, acceptInput: true}); // Us.
 			}
 			else {
 				$('#' + strId + '-cursor').css({display: 'none'});
-				this._map.fire('changefocuswidget', {winId: 0, dialog: null}); // Editor.
 			}
 		} else if (e.action === 'close') {
 			parent = this._getParentId(e.id);
@@ -380,7 +380,6 @@ L.Control.LokDialog = L.Control.extend({
 		// set the position of the cursor container element
 		L.DomUtil.setStyle(this._dialogs[dlgId].cursor, 'left', x + 'px');
 		L.DomUtil.setStyle(this._dialogs[dlgId].cursor, 'top', y + 'px');
-		this._map.focus();
 	},
 
 	_createDialogCursor: function(dialogId) {
@@ -391,7 +390,7 @@ L.Control.LokDialog = L.Control.extend({
 		L.DomUtil.addClass(cursor, 'blinking-cursor');
 	},
 
-	focus: function(dlgId) {
+	focus: function(dlgId, acceptInput) {
 		// In case of the sidebar we should be careful about
 		// grabbing the focus from the main window.
 		if (this._isSidebar(dlgId)) {
@@ -410,7 +409,7 @@ L.Control.LokDialog = L.Control.extend({
 
 		this._map.setWinId(dlgId);
 		if (dlgId in this._dialogs) {
-			this._map.focus();
+			this._map.focus(acceptInput);
 		}
 	},
 
@@ -963,7 +962,7 @@ L.Control.LokDialog = L.Control.extend({
 			// We lost the focus.
 			this._onEditorGotFocus();
 		} else {
-			this.focus(e.winId);
+			this.focus(e.winId, e.acceptInput);
 		}
 	},
 
diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index 863e2a4f4..afd66ef8b 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -1336,7 +1336,10 @@ L.Map = L.Evented.extend({
 	},
 
 	// Change the focus to a dialog or editor.
-	_changeFocusWidget: function (dialog, winId) {
+	// @dialog is the instance of the dialog class.
+	// @winId is the ID of the dialog/sidebar, or 0 for the editor.
+	// @acceptInput iff defined, map.focus is called and passed to it.
+	_changeFocusWidget: function (dialog, winId, acceptInput) {
 		if (!this._loaded) { return; }
 
 		this._winId = winId;
@@ -1345,6 +1348,9 @@ L.Map = L.Evented.extend({
 		var doclayer = this._docLayer;
 		if (doclayer)
 			doclayer._updateCursorAndOverlay();
+
+		if (acceptInput !== undefined)
+			this.focus(acceptInput);
 	},
 
 	// Our browser tab lost focus.
@@ -1374,7 +1380,7 @@ L.Map = L.Evented.extend({
 		if (e.winId === 0) {
 			this._onEditorGotFocus();
 		} else {
-			this._changeFocusWidget(e.dialog, e.winId);
+			this._changeFocusWidget(e.dialog, e.winId, e.acceptInput);
 		}
 	},
 


More information about the Libreoffice-commits mailing list