[MediaWiki-commits] [Gerrit] mediawiki...VisualEditor[master]: NWE: Don't attempt to set selection on unattached textarea

2018-01-22 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/405662 )

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
---
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:
  jenkins-bot: Verified
  Jforrester: Looks good to me, approved



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/405662
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ic9a43e3cf12d4cc566cebb328f8e807e464af634
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Esanders 
Gerrit-Reviewer: DLynch 
Gerrit-Reviewer: Jforrester 
Gerrit-Reviewer: jenkins-bot <>

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


[MediaWiki-commits] [Gerrit] mediawiki...VisualEditor[master]: NWE: Don't attempt to set selection on unattached textarea

2018-01-21 Thread Esanders (Code Review)
Esanders has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/405662 )

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
---
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, 10 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor 
refs/changes/62/405662/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..d9f9d40 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,7 @@
 
// 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();
+   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/405662
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: master
Gerrit-Owner: Esanders 

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