IAlex has uploaded a new change for review.

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


Change subject: Add support for "tabindex" in HTMLFormField subclasses
......................................................................

Add support for "tabindex" in HTMLFormField subclasses

It is already set for some fields in Special:Block, but are
discarded by HTMLForm and its fields.

Some notes:
- fields with multiple inputs (radio, select and other, select
  or other) will have the same tabindex set on all elements
- Some items such as multi-select and check matrix are not yet
  implemented

Change-Id: I3e1ba7f16f3a3183f231afcf60dd392ce6d6eb6b
---
M includes/HTMLForm.php
1 file changed, 38 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/14/62014/1

diff --git a/includes/HTMLForm.php b/includes/HTMLForm.php
index 5e3bb06..deb2a0d 100644
--- a/includes/HTMLForm.php
+++ b/includes/HTMLForm.php
@@ -1617,7 +1617,7 @@
                # TODO: Enforce pattern, step, required, readonly on the server 
side as
                # well
                $allowedParams = array( 'min', 'max', 'pattern', 'title', 
'step',
-                       'placeholder', 'list', 'maxlength' );
+                       'placeholder', 'list', 'maxlength', 'tabindex' );
                foreach ( $allowedParams as $param ) {
                        if ( isset( $this->mParams[$param] ) ) {
                                $attribs[$param] = $this->mParams[$param];
@@ -1692,8 +1692,10 @@
                        $attribs['readonly'] = 'readonly';
                }
 
-               if ( isset( $this->mParams['placeholder'] ) ) {
-                       $attribs['placeholder'] = $this->mParams['placeholder'];
+               foreach ( array( 'placeholder', 'tabindex' ) as $param ) {
+                       if ( isset( $this->mParams[$param] ) ) {
+                               $attribs[$param] = $this->mParams[$param];
+                       }
                }
 
                foreach ( array( 'required', 'autofocus' ) as $param ) {
@@ -1793,6 +1795,10 @@
 
                if ( !empty( $this->mParams['disabled'] ) ) {
                        $attr['disabled'] = 'disabled';
+               }
+
+               if ( isset( $this->mParams['tabindex'] ) ) {
+                       $attr['tabindex'] = $this->mParams['tabindex'];
                }
 
                if ( $this->mClass !== '' ) {
@@ -1897,6 +1903,10 @@
                // If the disabled param is set, disable all the options
                if ( !empty( $this->mParams['disabled'] ) ) {
                        $attribs['disabled'] = 'disabled';
+               }
+
+               if ( isset( $this->mParams['tabindex'] ) ) {
+                       $attribs['tabindex'] = $this->mParams['tabindex'];
                }
 
                // Build the column headers
@@ -2041,6 +2051,10 @@
                        $select->setAttribute( 'disabled', 'disabled' );
                }
 
+               if ( isset( $this->mParams['tabindex'] ) ) {
+                       $select->setAttribute( 'tabindex', 
$this->mParams['tabindex'] );
+               }
+
                if ( $this->mClass !== '' ) {
                        $select->setAttribute( 'class', $this->mClass );
                }
@@ -2099,6 +2113,11 @@
                if ( !empty( $this->mParams['disabled'] ) ) {
                        $select->setAttribute( 'disabled', 'disabled' );
                        $tbAttribs['disabled'] = 'disabled';
+               }
+
+               if ( isset( $this->mParams['tabindex'] ) ) {
+                       $select->setAttribute( 'tabindex', 
$this->mParams['tabindex'] );
+                       $tbAttribs['tabindex'] = $this->mParams['tabindex'];
                }
 
                $select = $select->getHTML();
@@ -2181,6 +2200,10 @@
 
                if ( !empty( $this->mParams['disabled'] ) ) {
                        $attribs['disabled'] = 'disabled';
+               }
+
+               if ( isset( $this->mParams['tabindex'] ) ) {
+                       $attribs['tabindex'] = $this->mParams['tabindex'];
                }
 
                foreach ( $options as $label => $info ) {
@@ -2337,6 +2360,10 @@
                        }
                }
 
+               if ( isset( $this->mParams['tabindex'] ) ) {
+                       $textAttribs['tabindex'] = $this->mParams['tabindex'];
+               }
+
                $textbox = Html::input(
                        $this->mName . '-other',
                        $value[2],
@@ -2453,6 +2480,10 @@
                $attribs = array();
                if ( !empty( $this->mParams['disabled'] ) ) {
                        $attribs['disabled'] = 'disabled';
+               }
+
+               if ( isset( $this->mParams['tabindex'] ) ) {
+                       $attribs['tabindex'] = $this->mParams['tabindex'];
                }
 
                # TODO: should this produce an unordered list perhaps?
@@ -2608,6 +2639,10 @@
                        $attr['disabled'] = 'disabled';
                }
 
+               if ( isset( $this->mParams['tabindex'] ) ) {
+                       $attr['tabindex'] = $this->mParams['tabindex'];
+               }
+
                return Html::input(
                        $this->mName,
                        $value,

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3e1ba7f16f3a3183f231afcf60dd392ce6d6eb6b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: IAlex <[email protected]>

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

Reply via email to