Page MenuHomePhabricator

AuthenticationRequest don't show help fields on forms
Closed, ResolvedPublic

Description

		$ret = [
			'username' => [
				'type' => 'string',
				'label' => wfMessage( 'userlogin-yourname' ),
				'help' => wfMessage( 'authmanager-username-help' ),
			],
			'password' => [
				'type' => 'password',
				'label' => wfMessage( $passwordLabel ),
				'help' => wfMessage( 'authmanager-password-help' ),
				'sensitive' => true,
			],
		];

Where are these help messages displayed/used?

Screenshot 2024-01-08 at 17.09.36.png (441×403 px, 24 KB)

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

In comparison to other HTMLForm stuff... Where the help text shows in light grey:

Screenshot 2024-01-08 at 16.45.41.png (849×344 px, 44 KB)

The fields seem to disappear in AuthManagerSpecialPage::fieldInfoToFormDescriptor()

And AuthManagerSpecialPage::mapSingleFieldInfo() and AuthManagerSpecialPage::mapFieldInfoTypeToFormDescriptorType() don't reference 'help'....

And then I see

			$descriptor += array_filter( [
				// help-message is omitted as it is usually not really useful for a web interface
				'label-message' => self::getField( $singleFieldInfo, 'label' ),
			] );

help-message isn't used in this tree (but is in HTMLForm)... And in some of the specialpage implementations for auth-y related stuff...

Does this mean help is incorrect? Why are we defining messages we basically ignore/don't display?

Then looking at HTMLForm itself...

*    'help'                -- message text for a message to use as a help text.
*    'help-message'        -- message key or object for a message to use as a help text.
*                             can be an array of msg key and then parameters to
*                             the message.
*                             Overwrites 'help-messages' and 'help'.
*    '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.

A little patch...

diff --git a/includes/specialpage/AuthManagerSpecialPage.php b/includes/specialpage/AuthManagerSpecialPage.php
index ba3db6e3618..a412ce109de 100644
--- a/includes/specialpage/AuthManagerSpecialPage.php
+++ b/includes/specialpage/AuthManagerSpecialPage.php
@@ -730,6 +730,10 @@ abstract class AuthManagerSpecialPage extends SpecialPage {
                                'label-message' => self::getField( $singleFieldInfo, 'label' ),
                        ] );
 
+                       if ( isset( $singleFieldInfo['help'] ) ) {
+                               $descriptor['help'] = $singleFieldInfo['help'];
+                       }
+
                        if ( isset( $singleFieldInfo['options'] ) ) {
                                $descriptor['options'] = array_flip( array_map( static function ( $message ) {
                                        /** @var Message $message */

gives

Screenshot 2024-01-08 at 17.48.14.png (379×302 px, 20 KB)

Which is missing a bit of styling CSS:

.oo-ui-labelWidget.oo-ui-inline-help {
  display: block;
  color: #54595d;
  font-size: 0.92857143em;
}

I will note that some those help messages aren't the most useful... But some of the others are...

It's still odd why we're defining them, then mostly ignoring them...

The help field in AuthentionReuqest field info is the API documentation. Sorry, this should have been documented. Using the same message for API docs and form help almost never works, and most form fields don't really need help text (or need something more specialized like placeholder text) so the idea is that form help would be added via the AuthChangeFormFields hook.

Change 988713 had a related patch set uploaded (by Gergő Tisza; author: Gergő Tisza):

[mediawiki/core@master] authmanager: Improve AuthenticationRequest docs

https://gerrit.wikimedia.org/r/988713

Change 988713 merged by jenkins-bot:

[mediawiki/core@master] authmanager: Improve AuthenticationRequest docs

https://gerrit.wikimedia.org/r/988713

Change 989878 had a related patch set uploaded (by Reedy; author: Gergő Tisza):

[mediawiki/core@REL1_41] authmanager: Improve AuthenticationRequest docs

https://gerrit.wikimedia.org/r/989878

Change 989879 had a related patch set uploaded (by Reedy; author: Gergő Tisza):

[mediawiki/core@REL1_40] authmanager: Improve AuthenticationRequest docs

https://gerrit.wikimedia.org/r/989879

Change 989880 had a related patch set uploaded (by Reedy; author: Gergő Tisza):

[mediawiki/core@REL1_39] authmanager: Improve AuthenticationRequest docs

https://gerrit.wikimedia.org/r/989880

Change 989878 merged by jenkins-bot:

[mediawiki/core@REL1_41] authmanager: Improve AuthenticationRequest docs

https://gerrit.wikimedia.org/r/989878

Change 989880 merged by jenkins-bot:

[mediawiki/core@REL1_39] authmanager: Improve AuthenticationRequest docs

https://gerrit.wikimedia.org/r/989880

Change 989879 merged by jenkins-bot:

[mediawiki/core@REL1_40] authmanager: Improve AuthenticationRequest docs

https://gerrit.wikimedia.org/r/989879

Nothing else to do here I think?

Feel free to reopen if you think more should be done.