jenkins-bot has submitted this change and it was merged.

Change subject: Dialog: trigger the primary action with ctrl-enter
......................................................................


Dialog: trigger the primary action with ctrl-enter

If a dialog has primary actions that are visible and not disabled, trigger the
first one when ctrl-enter is pressed.

Bug: T125860
Change-Id: I6b5cee5e76ca534a8f124c99c7dc67fa64f42ab6
---
M src/Dialog.js
1 file changed, 11 insertions(+), 7 deletions(-)

Approvals:
  Bartosz Dziewoński: Looks good to me, approved
  Esanders: Looks good to me, but someone else must approve
  jenkins-bot: Verified



diff --git a/src/Dialog.js b/src/Dialog.js
index a4ada70..70cfcf7 100644
--- a/src/Dialog.js
+++ b/src/Dialog.js
@@ -135,10 +135,18 @@
  * @param {jQuery.Event} e Key down event
  */
 OO.ui.Dialog.prototype.onDialogKeyDown = function ( e ) {
-       if ( e.which === OO.ui.Keys.ESCAPE ) {
+       var actions;
+       if ( e.which === OO.ui.Keys.ESCAPE && this.constructor.static.escapable 
) {
                this.executeAction( '' );
                e.preventDefault();
                e.stopPropagation();
+       } else if ( e.which === OO.ui.Keys.ENTER && e.ctrlKey ) {
+               actions = this.actions.get( { flags: 'primary', visible: true, 
disabled: false } );
+               if ( actions.length > 0 ) {
+                       this.executeAction( actions[ 0 ].getAction() );
+                       e.preventDefault();
+                       e.stopPropagation();
+               }
        }
 };
 
@@ -229,9 +237,7 @@
                        );
                        this.actions.add( this.getActionWidgets( actions ) );
 
-                       if ( this.constructor.static.escapable ) {
-                               this.$element.on( 'keydown', 
this.onDialogKeyDownHandler );
-                       }
+                       this.$element.on( 'keydown', 
this.onDialogKeyDownHandler );
                }, this );
 };
 
@@ -242,9 +248,7 @@
        // Parent method
        return OO.ui.Dialog.parent.prototype.getTeardownProcess.call( this, 
data )
                .first( function () {
-                       if ( this.constructor.static.escapable ) {
-                               this.$element.off( 'keydown', 
this.onDialogKeyDownHandler );
-                       }
+                       this.$element.off( 'keydown', 
this.onDialogKeyDownHandler );
 
                        this.actions.clear();
                        this.currentAction = null;

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I6b5cee5e76ca534a8f124c99c7dc67fa64f42ab6
Gerrit-PatchSet: 2
Gerrit-Project: oojs/ui
Gerrit-Branch: master
Gerrit-Owner: DLynch <[email protected]>
Gerrit-Reviewer: Bartosz Dziewoński <[email protected]>
Gerrit-Reviewer: DLynch <[email protected]>
Gerrit-Reviewer: Esanders <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to