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

Change subject: MenuWidget: Add option to specify an extra widget for mouse 
events
......................................................................


MenuWidget: Add option to specify an extra widget for mouse events

Otherwise the mousedown event will both open and close the menu.

Bug: 67821
Change-Id: I481f582f27a7f91e2745d2e3fa31761537e88d56
---
M src/widgets/InlineMenuWidget.js
M src/widgets/MenuWidget.js
2 files changed, 4 insertions(+), 2 deletions(-)

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



diff --git a/src/widgets/InlineMenuWidget.js b/src/widgets/InlineMenuWidget.js
index 088aa96..82ada68 100644
--- a/src/widgets/InlineMenuWidget.js
+++ b/src/widgets/InlineMenuWidget.js
@@ -28,7 +28,7 @@
        OO.ui.TitledElement.call( this, this.$label, config );
 
        // Properties
-       this.menu = new OO.ui.MenuWidget( $.extend( { '$': this.$ }, 
config.menu ) );
+       this.menu = new OO.ui.MenuWidget( $.extend( { '$': this.$, 'widget': 
this }, config.menu ) );
        this.$handle = this.$( '<span>' );
 
        // Events
diff --git a/src/widgets/MenuWidget.js b/src/widgets/MenuWidget.js
index 861ee83..7219e9a 100644
--- a/src/widgets/MenuWidget.js
+++ b/src/widgets/MenuWidget.js
@@ -10,6 +10,7 @@
  * @constructor
  * @param {Object} [config] Configuration options
  * @cfg {OO.ui.InputWidget} [input] Input to bind keyboard handlers to
+ * @cfg {OO.ui.Widget} [widget] Widget to bind mouse handlers to
  * @cfg {boolean} [autoHide=true] Hide the menu when the mouse is pressed 
outside the menu
  */
 OO.ui.MenuWidget = function OoUiMenuWidget( config ) {
@@ -28,6 +29,7 @@
        this.newItems = null;
        this.autoHide = config.autoHide === undefined || !!config.autoHide;
        this.$input = config.input ? config.input.$input : null;
+       this.$widget = config.widget ? config.widget.$element : null;
        this.$previousFocus = null;
        this.isolated = !config.input;
        this.onKeyDownHandler = OO.ui.bind( this.onKeyDown, this );
@@ -52,7 +54,7 @@
  * @param {jQuery.Event} e Key down event
  */
 OO.ui.MenuWidget.prototype.onDocumentMouseDown = function ( e ) {
-       if ( !$.contains( this.$element[0], e.target ) ) {
+       if ( !$.contains( this.$element[0], e.target ) && ( !this.$widget || 
!$.contains( this.$widget[0], e.target ) ) ) {
                this.toggle( false );
        }
 };

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I481f582f27a7f91e2745d2e3fa31761537e88d56
Gerrit-PatchSet: 4
Gerrit-Project: oojs/ui
Gerrit-Branch: master
Gerrit-Owner: Esanders <[email protected]>
Gerrit-Reviewer: Krinkle <[email protected]>
Gerrit-Reviewer: Trevor Parscal <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to