jenkins-bot has submitted this change and it was merged.
Change subject: Reinstate keypress filtering for Firefox
......................................................................
Reinstate keypress filtering for Firefox
Partially revert I277b92b9d11bfda01a92f3e615ca674feb920a1a , because the
keypress event is still needed on Firefox in certain cases, e.g. pressing
Home when the selection contains an image (e.g. "x<img src'#'>").
Change-Id: I7592cfa64d660d30ca7524ee39bf50ac149d9b03
---
M src/ce/ve.ce.Surface.js
1 file changed, 19 insertions(+), 1 deletion(-)
Approvals:
Catrope: Looks good to me, approved
jenkins-bot: Verified
diff --git a/src/ce/ve.ce.Surface.js b/src/ce/ve.ce.Surface.js
index 725b6d9..3450a1d 100644
--- a/src/ce/ve.ce.Surface.js
+++ b/src/ce/ve.ce.Surface.js
@@ -1208,8 +1208,26 @@
/**
* Handle document key press events.
+ *
+ * @method
+ * @param {jQuery.Event} e Key press event
*/
-ve.ce.Surface.prototype.onDocumentKeyPress = function () {
+ve.ce.Surface.prototype.onDocumentKeyPress = function ( e ) {
+ // Filter out non-character keys. Doing this prevents:
+ // * Unexpected content deletion when selection is not collapsed and
the user presses, for
+ // example, the Home key (Firefox fires 'keypress' for it)
+ // TODO: Should be covered with Selenium tests.
+ if (
+ // Catches most keys that don't produce output (charCode === 0,
thus no character)
+ e.which === 0 || e.charCode === 0 ||
+ // Opera 12 doesn't always adhere to that convention
+ e.keyCode === OO.ui.Keys.TAB || e.keyCode === OO.ui.Keys.ESCAPE
||
+ // Ignore all keypresses with Ctrl / Cmd modifier keys
+ ve.ce.isShortcutKey( e )
+ ) {
+ return;
+ }
+
this.handleInsertion();
};
--
To view, visit https://gerrit.wikimedia.org/r/187884
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I7592cfa64d660d30ca7524ee39bf50ac149d9b03
Gerrit-PatchSet: 2
Gerrit-Project: VisualEditor/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Divec <[email protected]>
Gerrit-Reviewer: Catrope <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits