From e5911a826c61649be1928d69f6ca7ff084ace485 Mon Sep 17 00:00:00 2001 From: Ed Sanders Date: Tue, 12 Jun 2018 15:46:48 +0100 Subject: [PATCH] Pass through 'helpInline' to OOUI FieldLayout and make true by default 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 | 3 +++ includes/htmlform/HTMLForm.php | 3 +++ includes/htmlform/HTMLFormField.php | 17 +++++++++++++++-- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/RELEASE-NOTES-1.32 b/RELEASE-NOTES-1.32 index f5522a6290..158fbe2648 100644 --- a/RELEASE-NOTES-1.32 +++ b/RELEASE-NOTES-1.32 @@ -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 == diff --git a/includes/htmlform/HTMLForm.php b/includes/htmlform/HTMLForm.php index 442a7cf6fa..0fa0406396 100644 --- a/includes/htmlform/HTMLForm.php +++ b/includes/htmlform/HTMLForm.php @@ -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. diff --git a/includes/htmlform/HTMLFormField.php b/includes/htmlform/HTMLFormField.php index 97e4b50551..f5d6e8cbb5 100644 --- a/includes/htmlform/HTMLFormField.php +++ b/includes/htmlform/HTMLFormField.php @@ -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 -- 2.20.1