Merge "OOUIHTMLForm: Prevent duplicate FieldsetLayout wrapping"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 16 Nov 2017 17:31:44 +0000 (17:31 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 16 Nov 2017 17:31:45 +0000 (17:31 +0000)
includes/htmlform/fields/HTMLMultiSelectField.php
includes/htmlform/fields/HTMLRadioField.php
resources/src/mediawiki/htmlform/ooui.styles.less
resources/src/mediawiki/mediawiki.diff.styles.css

index 515166c..238b2b4 100644 (file)
@@ -132,13 +132,17 @@ class HTMLMultiSelectField extends HTMLFormField implements HTMLNestedFilterable
        /**
         * Get the OOUI version of this field.
         *
+        * Returns OOUI\CheckboxMultiselectInputWidget for fields that only have one section,
+        * string otherwise.
+        *
         * @since 1.28
         * @param string[] $value
-        * @return OOUI\CheckboxMultiselectInputWidget
+        * @return string|OOUI\CheckboxMultiselectInputWidget
         */
        public function getInputOOUI( $value ) {
                $this->mParent->getOutput()->addModules( 'oojs-ui-widgets' );
 
+               $hasSections = false;
                $optionsOouiSections = [];
                $options = $this->getOptions();
                // If the options are supposed to be split into sections, each section becomes a separate
@@ -147,6 +151,7 @@ class HTMLMultiSelectField extends HTMLFormField implements HTMLNestedFilterable
                        if ( is_array( $section ) ) {
                                $optionsOouiSections[ $label ] = Xml::listDropDownOptionsOoui( $section );
                                unset( $options[$label] );
+                               $hasSections = true;
                        }
                }
                // If anything remains in the array, they are sectionless options. Put them in a separate widget
@@ -158,7 +163,7 @@ class HTMLMultiSelectField extends HTMLFormField implements HTMLNestedFilterable
                        );
                }
 
-               $out = '';
+               $out = [];
                foreach ( $optionsOouiSections as $sectionLabel => $optionsOoui ) {
                        $attr = [];
                        $attr['name'] = "{$this->mName}[]";
@@ -185,16 +190,22 @@ class HTMLMultiSelectField extends HTMLFormField implements HTMLNestedFilterable
 
                        $widget = new OOUI\CheckboxMultiselectInputWidget( $attr );
                        if ( $sectionLabel ) {
-                               $out .= new OOUI\FieldsetLayout( [
+                               $out[] = new OOUI\FieldsetLayout( [
                                        'items' => [ $widget ],
                                        'label' => $sectionLabel,
                                ] );
                        } else {
-                               $out .= $widget;
+                               $out[] = $widget;
                        }
                }
 
-               return $out;
+               if ( !$hasSections ) {
+                       // Directly return the only OOUI\CheckboxMultiselectInputWidget.
+                       // This allows it to be made infusable and later tweaked by JS code.
+                       return $out[ 0 ];
+               }
+
+               return implode( '', $out );
        }
 
        /**
index 77ea7cd..c98e1ec 100644 (file)
@@ -72,10 +72,6 @@ class HTMLRadioField extends HTMLFormField {
                ) );
        }
 
-       protected function shouldInfuseOOUI() {
-               return true;
-       }
-
        public function formatOptions( $options, $value ) {
                global $wgUseMediaWikiUIEverywhere;
 
index 1607489..e78a4ca 100644 (file)
@@ -1,4 +1,4 @@
-/* OOUIHTMLForm styles */
+// OOUIHTMLForm styles
 .mw-htmlform-ooui-wrapper.oo-ui-panelLayout-padded {
        padding: 1em 1.25em 1.25em;
 }
        }
 }
 
-/* Flatlist styling for PHP widgets... */
+// HACK: Hide empty fieldsetLayoutHeaders, until T180535 isn't resolved
+.oo-ui-fieldsetLayout:not( .oo-ui-labelElement ):not( .oo-ui-iconElement ) > .oo-ui-fieldsetLayout-header {
+       display: none;
+}
+
+// Flatlist styling for PHP widgets...
 .mw-htmlform-flatlist .oo-ui-fieldLayout-align-inline,
-/* ...and for JS widgets */
+// ...and for JS widgets
 .mw-htmlform-flatlist .oo-ui-radioOptionWidget,
 .mw-htmlform-flatlist .oo-ui-checkboxMultioptionWidget {
        display: inline-block;
index 1f6e54c..7260a0a 100644 (file)
@@ -137,6 +137,7 @@ td.diff-marker {
 .mw-diff-movedpara-left:hover,
 .mw-diff-movedpara-right:hover {
        text-decoration: none;
+       color: transparent;
 }
 
 .mw-diff-movedpara-left:after,