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

Change subject: [BREAKING CHANGE] If no $overlay is specified, default to 
this.$element
......................................................................


[BREAKING CHANGE] If no $overlay is specified, default to this.$element

Using the body as a default is a bad idea. Using the nearest
oo-ui-window-overlay works for isolated windows but not for
non-isolated windows (because this.$element isn't attached
yet in the constructor, but this.$.$iframe is). So instead,
just put dropdowns inline if there is no $overlay.

This fixes the bug where the combo box in the demo has its
menu display below the text due to z-index issues; this is
exactly what made Trevor say that using the body as a
default overlay is a bad idea in the first place.

This does break automatic overlay finding for widgets
inside of isolated windows, though, but that's easily
fixed by passing overlay: this.$overlay.

Bonus: actually pass the right config.$ to the menu in
ComboBoxWidget.

Change-Id: I39df86373ea1ca112eca85bbcb474495eb25b265
---
M src/widgets/ComboBoxWidget.js
M src/widgets/LookupInputWidget.js
2 files changed, 11 insertions(+), 13 deletions(-)

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



diff --git a/src/widgets/ComboBoxWidget.js b/src/widgets/ComboBoxWidget.js
index 65e3793..a064187 100644
--- a/src/widgets/ComboBoxWidget.js
+++ b/src/widgets/ComboBoxWidget.js
@@ -8,7 +8,7 @@
  * @param {Object} [config] Configuration options
  * @cfg {Object} [menu] Configuration options to pass to menu widget
  * @cfg {Object} [input] Configuration options to pass to input widget
- * @cfg {jQuery} [$overlay] Overlay layer; defaults to the current window's 
overlay.
+ * @cfg {jQuery} [$overlay] Overlay layer; defaults to relative positioning
  */
 OO.ui.ComboBoxWidget = function OoUiComboBoxWidget( config ) {
        // Configuration initialization
@@ -18,16 +18,18 @@
        OO.ui.ComboBoxWidget.super.call( this, config );
 
        // Properties
-       this.$overlay = config.$overlay || ( this.$.$iframe || this.$element 
).closest( '.oo-ui-window' ).children( '.oo-ui-window-overlay' );
-       if ( this.$overlay.length === 0 ) {
-               this.$overlay = this.$( 'body' );
-       }
+       this.$overlay = config.$overlay || this.$element;
        this.input = new OO.ui.TextInputWidget( $.extend(
                { $: this.$, indicator: 'down', disabled: this.isDisabled() },
                config.input
        ) );
        this.menu = new OO.ui.TextInputMenuWidget( this.input, $.extend(
-               { $: this.$, widget: this, input: this.input, disabled: 
this.isDisabled() },
+               {
+                       $: OO.ui.Element.getJQuery( this.$overlay ),
+                       widget: this,
+                       input: this.input,
+                       disabled: this.isDisabled()
+               },
                config.menu
        ) );
 
diff --git a/src/widgets/LookupInputWidget.js b/src/widgets/LookupInputWidget.js
index 82c864e..af4abc3 100644
--- a/src/widgets/LookupInputWidget.js
+++ b/src/widgets/LookupInputWidget.js
@@ -9,7 +9,7 @@
  * @constructor
  * @param {OO.ui.TextInputWidget} input Input widget
  * @param {Object} [config] Configuration options
- * @cfg {jQuery} [$overlay] Overlay layer; defaults to the current window's 
overlay.
+ * @cfg {jQuery} [$overlay] Overlay for dropdown; defaults to relative 
positioning
  */
 OO.ui.LookupInputWidget = function OoUiLookupInputWidget( input, config ) {
        // Config intialization
@@ -17,10 +17,7 @@
 
        // Properties
        this.lookupInput = input;
-       this.$overlay = config.$overlay || ( this.$.$iframe || this.$element 
).closest( '.oo-ui-window' ).children( '.oo-ui-window-overlay' );
-       if ( this.$overlay.length === 0 ) {
-               this.$overlay = this.$( 'body' );
-       }
+       this.$overlay = config.$overlay || this.$element;
        this.lookupMenu = new OO.ui.TextInputMenuWidget( this, {
                $: OO.ui.Element.getJQuery( this.$overlay ),
                input: this.lookupInput,
@@ -32,8 +29,6 @@
        this.populating = false;
 
        // Events
-       this.$overlay.append( this.lookupMenu.$element );
-
        this.lookupInput.$input.on( {
                focus: this.onLookupInputFocus.bind( this ),
                blur: this.onLookupInputBlur.bind( this ),
@@ -44,6 +39,7 @@
        // Initialization
        this.$element.addClass( 'oo-ui-lookupWidget' );
        this.lookupMenu.$element.addClass( 'oo-ui-lookupWidget-menu' );
+       this.$overlay.append( this.lookupMenu.$element );
 };
 
 /* Methods */

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I39df86373ea1ca112eca85bbcb474495eb25b265
Gerrit-PatchSet: 2
Gerrit-Project: oojs/ui
Gerrit-Branch: master
Gerrit-Owner: Catrope <[email protected]>
Gerrit-Reviewer: Esanders <[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