HTMLSelectOtherFields: Have 'other' always as first element
authorumherirrender <umherirrender_de.wp@web.de>
Thu, 10 Apr 2014 15:31:25 +0000 (17:31 +0200)
committerIAlex <codereview@emsenhuber.ch>
Sun, 29 Jun 2014 11:50:52 +0000 (11:50 +0000)
The other field is in most case the default item selected in the drop
down box when a page is loaded. But when the last item is selected you
have to scroll to the top to select one of the first item, which are
often the common or most used items.

So adding the 'other' always as first item to the list.
For the HTMLSelectAndOtherField this was before
If4175332405d26c7ff2e8fbe100bcad61762ce6f, so that is fixing a
regression. In my opinion it should be the same for both types.

Follow-Up: If4175332405d26c7ff2e8fbe100bcad61762ce6f
Change-Id: I82f31e260d63bfaa6a4a94908e019feb9e0f2421

includes/htmlform/HTMLSelectAndOtherField.php
includes/htmlform/HTMLSelectOrOtherField.php

index 19b2f7c..65176dd 100644 (file)
@@ -26,7 +26,8 @@ class HTMLSelectAndOtherField extends HTMLSelectField {
                        throw new MWException( 'HTMLSelectAndOtherField called without any options' );
                }
                if ( !in_array( 'other', $this->mOptions, true ) ) {
-                       $this->mOptions[$params['other']] = 'other';
+                       // Have 'other' always as first element
+                       $this->mOptions = array( $params['other'] => 'other' ) + $this->mOptions;
                }
                $this->mFlatOptions = self::flattenOptions( $this->getOptions() );
 
index a001c43..cbf7d12 100644 (file)
@@ -12,7 +12,8 @@ class HTMLSelectOrOtherField extends HTMLTextField {
                                isset( $params['other'] )
                                        ? $params['other']
                                        : wfMessage( 'htmlform-selectorother-other' )->text();
-                       $this->mOptions[$msg] = 'other';
+                       // Have 'other' always as first element
+                       $this->mOptions = array( $msg => 'other' ) + $this->mOptions;
                }
 
        }