From 03b557f1672f190826ae8fd7c1528a6a6070be18 Mon Sep 17 00:00:00 2001 From: Ed Sanders Date: Fri, 29 Nov 2024 17:01:32 +0000 Subject: [PATCH] Dialogs: Go back or close when pressing escape Decide based on the currently available actions. Change-Id: Ida805efbf14071967bf2359788486028fb6c9a09 --- modules/ve-mw/ui/dialogs/ve.ui.MWMediaDialog.js | 11 +++++++++++ modules/ve-mw/ui/dialogs/ve.ui.MWSaveDialog.js | 11 +++++++++++ .../ve-mw/ui/dialogs/ve.ui.MWTransclusionDialog.js | 11 +++++++++++ 3 files changed, 33 insertions(+) diff --git a/modules/ve-mw/ui/dialogs/ve.ui.MWMediaDialog.js b/modules/ve-mw/ui/dialogs/ve.ui.MWMediaDialog.js index d619994e88..6a45cb0573 100644 --- a/modules/ve-mw/ui/dialogs/ve.ui.MWMediaDialog.js +++ b/modules/ve-mw/ui/dialogs/ve.ui.MWMediaDialog.js @@ -173,6 +173,17 @@ ve.ui.MWMediaDialog.static.getImportRules = function () { /* Methods */ +/** + * @inheritdoc + */ +ve.ui.MWMediaDialog.prototype.getEscapeAction = function () { + const backOrClose = this.actions.get( { flags: [ 'back', 'close' ], visible: true } ); + if ( backOrClose.length ) { + return backOrClose[ 0 ].getAction(); + } + return null; +}; + /** * @inheritdoc */ diff --git a/modules/ve-mw/ui/dialogs/ve.ui.MWSaveDialog.js b/modules/ve-mw/ui/dialogs/ve.ui.MWSaveDialog.js index fa8c0df454..aaccdaa4d2 100644 --- a/modules/ve-mw/ui/dialogs/ve.ui.MWSaveDialog.js +++ b/modules/ve-mw/ui/dialogs/ve.ui.MWSaveDialog.js @@ -876,6 +876,17 @@ ve.ui.MWSaveDialog.prototype.getTeardownProcess = function ( data ) { } ); }; +/** + * @inheritdoc + */ +ve.ui.MWSaveDialog.prototype.getEscapeAction = function () { + const backOrClose = this.actions.get( { flags: [ 'back', 'close' ], visible: true } ); + if ( backOrClose.length ) { + return backOrClose[ 0 ].getAction(); + } + return null; +}; + /** * @inheritdoc */ diff --git a/modules/ve-mw/ui/dialogs/ve.ui.MWTransclusionDialog.js b/modules/ve-mw/ui/dialogs/ve.ui.MWTransclusionDialog.js index a48bfa18c4..9344e56785 100644 --- a/modules/ve-mw/ui/dialogs/ve.ui.MWTransclusionDialog.js +++ b/modules/ve-mw/ui/dialogs/ve.ui.MWTransclusionDialog.js @@ -68,6 +68,17 @@ ve.ui.MWTransclusionDialog.static.isSmallScreen = function () { /* Methods */ +/** + * @inheritdoc + */ +ve.ui.MWTransclusionDialog.prototype.getEscapeAction = function () { + const backOrClose = this.actions.get( { flags: [ 'back', 'close' ], visible: true } ); + if ( backOrClose.length ) { + return backOrClose[ 0 ].getAction(); + } + return null; +}; + /** * Handle outline controls move events. *