From 7ffea90b5cae8031dbd3dfadc7cc6933b0c6701d Mon Sep 17 00:00:00 2001 From: umherirrender Date: Thu, 10 Apr 2014 17:31:25 +0200 Subject: [PATCH] HTMLSelectOtherFields: Have 'other' always as first element 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 | 3 ++- includes/htmlform/HTMLSelectOrOtherField.php | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/includes/htmlform/HTMLSelectAndOtherField.php b/includes/htmlform/HTMLSelectAndOtherField.php index 19b2f7c56f..65176dd7ac 100644 --- a/includes/htmlform/HTMLSelectAndOtherField.php +++ b/includes/htmlform/HTMLSelectAndOtherField.php @@ -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() ); diff --git a/includes/htmlform/HTMLSelectOrOtherField.php b/includes/htmlform/HTMLSelectOrOtherField.php index a001c437fe..cbf7d122d7 100644 --- a/includes/htmlform/HTMLSelectOrOtherField.php +++ b/includes/htmlform/HTMLSelectOrOtherField.php @@ -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; } } -- 2.20.1