[Libreoffice-commits] online.git: loleaflet/src
Henry Castro (via logerrit)
logerrit at kemper.freedesktop.org
Wed Jan 8 17:23:30 UTC 2020
loleaflet/src/layer/marker/TextInput.js | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
New commits:
commit 368f6ff70ee063c4d7322051237c29287d2d296e
Author: Henry Castro <hcastro at collabora.com>
AuthorDate: Wed Jan 8 11:11:46 2020 -0400
Commit: Henry Castro <hcastro at collabora.com>
CommitDate: Wed Jan 8 18:23:12 2020 +0100
loleaflet: prevent auto focus when the page is loaded
It has been added an attribute 'disabled' when permission is
'readonly', otherwise it is removed
Change-Id: I64a4cf9a7a754d66862e55805202358b9f83caf8
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/86442
Reviewed-by: Henry Castro <hcastro at collabora.com>
Tested-by: Henry Castro <hcastro at collabora.com>
diff --git a/loleaflet/src/layer/marker/TextInput.js b/loleaflet/src/layer/marker/TextInput.js
index ec431c267..4a0914b4f 100644
--- a/loleaflet/src/layer/marker/TextInput.js
+++ b/loleaflet/src/layer/marker/TextInput.js
@@ -64,6 +64,7 @@ L.TextInput = L.Layer.extend({
this._emptyArea();
+ this._map.on('updatepermission', this._onPermission, this);
L.DomEvent.on(this._textArea, 'focus blur', this._onFocusBlur, this);
// Do not wait for a 'focus' event to attach events if the
@@ -80,13 +81,22 @@ L.TextInput = L.Layer.extend({
if (this._container) {
this.getPane().removeChild(this._container);
}
- L.DomEvent.off(this._textArea, 'focus blur', this._onFocusBlur, this);
+ this._map.off('updatepermission', this._onPermission, this);
+ L.DomEvent.off(this._textArea, 'focus blur', this._onFocusBlur, this);
L.DomEvent.off(this._map.getContainer(), 'mousedown touchstart', this._abortComposition, this);
this._map.removeLayer(this._cursorHandler);
},
+ _onPermission: function(e) {
+ if (e.perm === 'edit') {
+ this._textArea.removeAttribute('disabled');
+ } else {
+ this._textArea.setAttribute('disabled', true);
+ }
+ },
+
_onFocusBlur: function(ev) {
this._fancyLog(ev.type, '');
@@ -191,6 +201,9 @@ L.TextInput = L.Layer.extend({
// See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/textarea#attr-wrap
this._textArea.setAttribute('wrap', 'off');
+ // Prevent autofocus
+ this._textArea.setAttribute('disabled', true);
+
this._setupStyles();
this._emptyArea();
More information about the Libreoffice-commits
mailing list