Pass through 'helpInline' to OOUI FieldLayout and make true by default
authorEd Sanders <esanders@wikimedia.org>
Tue, 12 Jun 2018 14:46:48 +0000 (15:46 +0100)
committerBartosz Dziewoński <matma.rex@gmail.com>
Fri, 17 Aug 2018 20:34:33 +0000 (22:34 +0200)
This change is meant to improve the layout of Special:Preferences in
particular, but it will affect any OOUI form using help messages. It
should be a harmless or beneficial change for most of them.

Previous behavior can be restored by passing `'help-inline' => false`
to the HTMLForm factory after 'help-message'/'help-messages'/'help'.

For example:

* Special:Preferences?ooui=1#mw-prefsection-watchlist
  * Before: https://phabricator.wikimedia.org/F25025213
  * After:  https://phabricator.wikimedia.org/F25025181

* Special:ChangeEmail
  * Before: https://phabricator.wikimedia.org/F25073327
  * After:  https://phabricator.wikimedia.org/F25073328

* Special:BotPasswords/foo
  * Before: https://phabricator.wikimedia.org/F25073324
  * After:  https://phabricator.wikimedia.org/F25073326

Bug: T181854
Change-Id: Ica67fe4081dfaa8eb9e8f56fdb93530750e47012

RELEASE-NOTES-1.32
includes/htmlform/HTMLForm.php
includes/htmlform/HTMLFormField.php

index f5522a6..158fbe2 100644 (file)
@@ -365,6 +365,9 @@ because of Phabricator reports.
 * (T198811) The following tables have had their UNIQUE indexes turned into
   proper PRIMARY KEYs for increased maintainability: interwiki, page_props,
   protected_titles and site_identifiers.
+* OOUI HTMLForm will now display help text inline after the input field,
+  rather than in a popup. Previous behavior can be restored by using
+  `'help-inline' => false`.
 * …
 
 == Compatibility ==
index 442a7cf..0fa0406 100644 (file)
@@ -76,6 +76,9 @@ use Wikimedia\ObjectFactory;
  *    'help-messages'       -- array of message keys/objects. As above, each item can
  *                             be an array of msg key and then parameters.
  *                             Overwrites 'help'.
+ *    'help-inline'         -- Whether help text (defined using options above) will be shown
+ *                             inline after the input field, rather than in a popup.
+ *                             Defaults to true. Only used by OOUI form fields.
  *    'notice'              -- message text for a message to use as a notice in the field.
  *                             Currently used by OOUI form fields only.
  *    'notice-messages'     -- array of message keys/objects to use for notice.
index 97e4b50..f5d6e8c 100644 (file)
@@ -619,6 +619,7 @@ abstract class HTMLFormField {
                        'errors' => $errors,
                        'notices' => $notices,
                        'infusable' => $infusable,
+                       'helpInline' => $this->isHelpInline(),
                ];
 
                $preloadModules = false;
@@ -679,8 +680,8 @@ abstract class HTMLFormField {
         * @return bool
         */
        protected function shouldInfuseOOUI() {
-               // Always infuse fields with help text, since the interface for it is nicer with JS
-               return $this->getHelpText() !== null;
+               // Always infuse fields with popup help text, since the interface for it is nicer with JS
+               return $this->getHelpText() !== null && !$this->isHelpInline();
        }
 
        /**
@@ -851,6 +852,18 @@ abstract class HTMLFormField {
                return $helptext;
        }
 
+       /**
+        * Determine if the help text should be displayed inline.
+        *
+        * Only applies to OOUI forms.
+        *
+        * @since 1.31
+        * @return bool
+        */
+       public function isHelpInline() {
+               return isset( $this->mParams['help-inline'] ) ? $this->mParams['help-inline'] : true;
+       }
+
        /**
         * Determine form errors to display and their classes
         * @since 1.20