Bartosz Dziewoński has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/391781 )

Change subject: OOUIHTMLForm: Prevent duplicate FieldsetLayout wrapping
......................................................................

OOUIHTMLForm: Prevent duplicate FieldsetLayout wrapping

The code in formatSection() assumed it was only called for the
toplevel section (the whole form), while it's actually called
for every subsection too. I think it was written before we added
support for subsections in OOUIHTMLForm.

Move code for toplevel section wrapping to wrapForm().

Bug: T180535
Change-Id: I6a88184d302a951be78387490404137acde3fa1a
---
M includes/htmlform/OOUIHTMLForm.php
1 file changed, 22 insertions(+), 9 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/81/391781/1

diff --git a/includes/htmlform/OOUIHTMLForm.php 
b/includes/htmlform/OOUIHTMLForm.php
index 1755e98..035b43f 100644
--- a/includes/htmlform/OOUIHTMLForm.php
+++ b/includes/htmlform/OOUIHTMLForm.php
@@ -182,16 +182,16 @@
                        return '';
                }
 
-               $config = [
-                       'items' => $fieldsHtml,
-               ];
+               $html = implode( '', $fieldsHtml );
+
                if ( $sectionName ) {
-                       $config['id'] = Sanitizer::escapeIdForAttribute( 
$sectionName );
+                       $html = Html::rawElement(
+                               'div',
+                               [ 'id' => Sanitizer::escapeIdForAttribute( 
$sectionName ) ],
+                               $html
+                       );
                }
-               if ( is_string( $this->mWrapperLegend ) ) {
-                       $config['label'] = $this->mWrapperLegend;
-               }
-               return new OOUI\FieldsetLayout( $config );
+               return $html;
        }
 
        /**
@@ -283,9 +283,22 @@
        }
 
        public function wrapForm( $html ) {
+               if ( is_string( $this->mWrapperLegend ) ) {
+                       $content = new OOUI\FieldsetLayout( [
+                               'label' => $this->mWrapperLegend,
+                               'items' => [
+                                       new OOUI\Widget( [
+                                               'content' => new 
OOUI\HtmlSnippet( $html )
+                                       ] ),
+                               ],
+                       ] );
+               } else {
+                       $content = new OOUI\HtmlSnippet( $html );
+               }
+
                $form = new OOUI\FormLayout( $this->getFormAttributes() + [
                        'classes' => [ 'mw-htmlform', 'mw-htmlform-ooui' ],
-                       'content' => new OOUI\HtmlSnippet( $html ),
+                       'content' => $content,
                ] );
 
                // Include a wrapper for style, if requested.

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6a88184d302a951be78387490404137acde3fa1a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Bartosz Dziewoński <[email protected]>

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

Reply via email to