Mailing List Archive

[MediaWiki-commits] [Gerrit] mediawiki...VisualEditor[wmf/1.31.0-wmf.17]: NWE: Don't attempt to set selection on unattached textarea
Jforrester has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/405933 )

Change subject: NWE: Don't attempt to set selection on unattached textarea
......................................................................

NWE: Don't attempt to set selection on unattached textarea

Prevents an exception being thrown in Firefox <= 52.

Bug: T185304
Change-Id: Ic9a43e3cf12d4cc566cebb328f8e807e464af634
(cherry picked from commit f2568c8d7db19b8ad594bbcff11194ed6e062677)
---
M modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.init.js
M modules/ve-mw/init/ve.init.mw.TempWikitextEditorWidget.js
2 files changed, 11 insertions(+), 1 deletion(-)


git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor refs/changes/33/405933/1

diff --git a/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.init.js b/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.init.js
index a737d41..832dadc 100644
--- a/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.init.js
+++ b/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.init.js
@@ -139,7 +139,8 @@

// Resize the textarea to fit content. We could do this more often (e.g. on change)
// but hopefully this temporary textarea won't be visible for too long.
- tempWikitextEditor.adjustSize().focus();
+ // Support: Firefox =< 52
+ tempWikitextEditor.adjustSize().moveCursorToStart();
ve.track( 'mwedit.ready', { mode: 'source' } );
}

diff --git a/modules/ve-mw/init/ve.init.mw.TempWikitextEditorWidget.js b/modules/ve-mw/init/ve.init.mw.TempWikitextEditorWidget.js
index 829ef78..5bc228c 100644
--- a/modules/ve-mw/init/ve.init.mw.TempWikitextEditorWidget.js
+++ b/modules/ve-mw/init/ve.init.mw.TempWikitextEditorWidget.js
@@ -34,9 +34,18 @@
} )
.val( config.value )
.on( 'input', config.onChange );
+};

+/**
+ * Focus the input and move the cursor to the start.
+ *
+ * @chainable
+ */
+mw.libs.ve.MWTempWikitextEditorWidget.prototype.moveCursorToStart = function () {
// Move cursor to start
this.$element[ 0 ].setSelectionRange( 0, 0 );
+ this.focus();
+ return this;
};

/**

--
To view, visit https://gerrit.wikimedia.org/r/405933
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic9a43e3cf12d4cc566cebb328f8e807e464af634
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: wmf/1.31.0-wmf.17
Gerrit-Owner: Jforrester <jforrester@wikimedia.org>
Gerrit-Reviewer: Esanders <esanders@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] mediawiki...VisualEditor[wmf/1.31.0-wmf.17]: NWE: Don't attempt to set selection on unattached textarea [ In reply to ]
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/405933 )

Change subject: NWE: Don't attempt to set selection on unattached textarea
......................................................................


NWE: Don't attempt to set selection on unattached textarea

Prevents an exception being thrown in Firefox <= 52.

Bug: T185304
Change-Id: Ic9a43e3cf12d4cc566cebb328f8e807e464af634
(cherry picked from commit f2568c8d7db19b8ad594bbcff11194ed6e062677)
---
M modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.init.js
M modules/ve-mw/init/ve.init.mw.TempWikitextEditorWidget.js
2 files changed, 11 insertions(+), 1 deletion(-)

Approvals:
Mattflaschen: Looks good to me, approved
jenkins-bot: Verified



diff --git a/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.init.js b/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.init.js
index a737d41..832dadc 100644
--- a/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.init.js
+++ b/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.init.js
@@ -139,7 +139,8 @@

// Resize the textarea to fit content. We could do this more often (e.g. on change)
// but hopefully this temporary textarea won't be visible for too long.
- tempWikitextEditor.adjustSize().focus();
+ // Support: Firefox =< 52
+ tempWikitextEditor.adjustSize().moveCursorToStart();
ve.track( 'mwedit.ready', { mode: 'source' } );
}

diff --git a/modules/ve-mw/init/ve.init.mw.TempWikitextEditorWidget.js b/modules/ve-mw/init/ve.init.mw.TempWikitextEditorWidget.js
index 829ef78..5bc228c 100644
--- a/modules/ve-mw/init/ve.init.mw.TempWikitextEditorWidget.js
+++ b/modules/ve-mw/init/ve.init.mw.TempWikitextEditorWidget.js
@@ -34,9 +34,18 @@
} )
.val( config.value )
.on( 'input', config.onChange );
+};

+/**
+ * Focus the input and move the cursor to the start.
+ *
+ * @chainable
+ */
+mw.libs.ve.MWTempWikitextEditorWidget.prototype.moveCursorToStart = function () {
// Move cursor to start
this.$element[ 0 ].setSelectionRange( 0, 0 );
+ this.focus();
+ return this;
};

/**

--
To view, visit https://gerrit.wikimedia.org/r/405933
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ic9a43e3cf12d4cc566cebb328f8e807e464af634
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: wmf/1.31.0-wmf.17
Gerrit-Owner: Jforrester <jforrester@wikimedia.org>
Gerrit-Reviewer: Esanders <esanders@wikimedia.org>
Gerrit-Reviewer: Mattflaschen <mflaschen@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits