Florianschmidtwelzow has uploaded a new change for review.

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

Change subject: Special:UserLogin: Don't show login button with rememberMe 
checkbox only
......................................................................

Special:UserLogin: Don't show login button with rememberMe checkbox only

If the only input field (apart from buttons) of the login form is
the rememberMe checkbox, the form shouldn't show the "Login" button
as it's clearly useless. This commit changes how the LoginSignupSpecialPage
decides, if a Log in button is needed or not (now excludes the login
button for checkbox fields, too).

Bug: T141471
Change-Id: Ib18a69582cb3f79d438ab009d8755f0d5e415bcb
---
M includes/specialpage/AuthManagerSpecialPage.php
M includes/specialpage/LoginSignupSpecialPage.php
2 files changed, 19 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/31/301431/1

diff --git a/includes/specialpage/AuthManagerSpecialPage.php 
b/includes/specialpage/AuthManagerSpecialPage.php
index c889b73..9938e11 100644
--- a/includes/specialpage/AuthManagerSpecialPage.php
+++ b/includes/specialpage/AuthManagerSpecialPage.php
@@ -569,12 +569,23 @@
                        } elseif ( array_key_exists( 'type', $item ) ) {
                                $class = HTMLForm::$typeMappings[$item['type']];
                        }
-                       return !is_a( $class, \HTMLInfoField::class, true ) &&
-                               !is_a( $class, \HTMLSubmitField::class, true );
+
+                       return $this->doesClassNeedsSubmitButton( $class );
                } );
        }
 
        /**
+        * Checks if the given class name needs a submit button or not.
+        *
+        * @param string $class The class name to check
+        * @return bool
+        */
+       protected function doesClassNeedsSubmitButton( $class ) {
+               return !is_a( $class, \HTMLInfoField::class, true ) &&
+                       !is_a( $class, \HTMLSubmitField::class, true );
+       }
+
+       /**
         * Adds a sequential tabindex starting from 1 to all form elements. 
This way the user can
         * use the tab key to traverse the form without having to step through 
all links and such.
         * @param $formDescriptor
diff --git a/includes/specialpage/LoginSignupSpecialPage.php 
b/includes/specialpage/LoginSignupSpecialPage.php
index 5dab221..56ac606 100644
--- a/includes/specialpage/LoginSignupSpecialPage.php
+++ b/includes/specialpage/LoginSignupSpecialPage.php
@@ -1275,6 +1275,12 @@
 
                $this->addTabIndex( $formDescriptor );
        }
+
+       protected function doesClassNeedsSubmitButton( $class ) {
+               // the rememberMe button doesn't need a submit button, too, 
like any other checkbox
+               return parent::doesClassNeedsSubmitButton( $class ) &&
+                       !is_a( $class, \HTMLCheckField::class, true );
+       }
 }
 
 /**

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib18a69582cb3f79d438ab009d8755f0d5e415bcb
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Florianschmidtwelzow <florian.schmidt.stargatewis...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to