jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/360905 )

Change subject: Avoid duplicate accesskey hints on OOUI widgets
......................................................................


Avoid duplicate accesskey hints on OOUI widgets

Values returned by `Linker::tooltipAndAccesskeyAttribs()` and
`Linker::titleAttrib( ..., 'withaccess' )` include an accesskey
hint in the title text. This is unnecessary when used for OOjs UI
widgets, since after the changes from T168408 they display an
accesskey hint automatically.

Also fixed some other accesskey bugs in HTMLForm which probably
no one ever ran into.

Bug: T168408
Change-Id: I63285b5bce3341875a6d82eba059623bf105ca62
---
M includes/EditPage.php
M includes/htmlform/HTMLFormField.php
M includes/htmlform/OOUIHTMLForm.php
M includes/htmlform/fields/HTMLCheckField.php
M includes/htmlform/fields/HTMLMultiSelectField.php
M includes/htmlform/fields/HTMLTextAreaField.php
M includes/htmlform/fields/HTMLTextField.php
7 files changed, 45 insertions(+), 16 deletions(-)

Approvals:
  jenkins-bot: Verified
  Jforrester: Looks good to me, approved



diff --git a/includes/EditPage.php b/includes/EditPage.php
index 229a36a..fc77006 100644
--- a/includes/EditPage.php
+++ b/includes/EditPage.php
@@ -3076,7 +3076,7 @@
                        'tabindex' => 1,
                        'size' => 60,
                        'spellcheck' => 'true',
-               ] + Linker::tooltipAndAccesskeyAttribs( 'summary' );
+               ];
        }
 
        /**
@@ -3097,6 +3097,7 @@
                $inputAttrs = null, $spanLabelAttrs = null
        ) {
                $inputAttrs = $this->getSummaryInputAttributes( $inputAttrs );
+               $inputAttrs += Linker::tooltipAndAccesskeyAttribs( 'summary' );
 
                $spanLabelAttrs = ( is_array( $spanLabelAttrs ) ? 
$spanLabelAttrs : [] ) + [
                        'class' => $this->missingSummary ? 'mw-summarymissed' : 
'mw-summary',
@@ -3132,6 +3133,10 @@
                $inputAttrs = OOUI\Element::configFromHtmlAttributes(
                        $this->getSummaryInputAttributes( $inputAttrs )
                );
+               $inputAttrs += [
+                       'title' => Linker::titleAttrib( 'summary' ),
+                       'accessKey' => Linker::accesskey( 'summary' ),
+               ];
 
                // For compatibility with old scripts and extensions, we want 
the legacy 'id' on the `<input>`
                $inputAttrs['inputId'] = $inputAttrs['id'];
@@ -4277,7 +4282,7 @@
                        $accesskey = null;
                        if ( isset( $options['tooltip'] ) ) {
                                $accesskey = $this->context->msg( 
"accesskey-{$options['tooltip']}" )->text();
-                               $title = Linker::titleAttrib( 
$options['tooltip'], 'withaccess' );
+                               $title = Linker::titleAttrib( 
$options['tooltip'] );
                        }
                        if ( isset( $options['title-message'] ) ) {
                                $title = $this->context->msg( 
$options['title-message'] )->text();
@@ -4355,8 +4360,7 @@
                $attribs = [
                        'name' => 'wpSave',
                        'tabindex' => ++$tabindex,
-               ] + Linker::tooltipAndAccesskeyAttribs( 'save' );
-
+               ];
                if ( $this->oouiEnabled ) {
                        $saveConfig = OOUI\Element::configFromHtmlAttributes( 
$attribs );
                        $buttons['save'] = new OOUI\ButtonInputWidget( [
@@ -4368,11 +4372,13 @@
                                'label' => $buttonLabel,
                                'infusable' => true,
                                'type' => 'submit',
+                               'title' => Linker::titleAttrib( 'save' ),
+                               'accessKey' => Linker::accesskey( 'save' ),
                        ] + $saveConfig );
                } else {
                        $buttons['save'] = Html::submitButton(
                                $buttonLabel,
-                               $attribs + [ 'id' => 'wpSave' ],
+                               $attribs + Linker::tooltipAndAccesskeyAttribs( 
'save' ) + [ 'id' => 'wpSave' ],
                                [ 'mw-ui-progressive' ]
                        );
                }
@@ -4380,7 +4386,7 @@
                $attribs = [
                        'name' => 'wpPreview',
                        'tabindex' => ++$tabindex,
-               ] + Linker::tooltipAndAccesskeyAttribs( 'preview' );
+               ];
                if ( $this->oouiEnabled ) {
                        $previewConfig = 
OOUI\Element::configFromHtmlAttributes( $attribs );
                        $buttons['preview'] = new OOUI\ButtonInputWidget( [
@@ -4390,18 +4396,20 @@
                                'useInputTag' => true,
                                'label' => $this->context->msg( 'showpreview' 
)->text(),
                                'infusable' => true,
-                               'type' => 'submit'
+                               'type' => 'submit',
+                               'title' => Linker::titleAttrib( 'preview' ),
+                               'accessKey' => Linker::accesskey( 'preview' ),
                        ] + $previewConfig );
                } else {
                        $buttons['preview'] = Html::submitButton(
                                $this->context->msg( 'showpreview' )->text(),
-                               $attribs + [ 'id' => 'wpPreview' ]
+                               $attribs + Linker::tooltipAndAccesskeyAttribs( 
'preview' ) + [ 'id' => 'wpPreview' ]
                        );
                }
                $attribs = [
                        'name' => 'wpDiff',
                        'tabindex' => ++$tabindex,
-               ] + Linker::tooltipAndAccesskeyAttribs( 'diff' );
+               ];
                if ( $this->oouiEnabled ) {
                        $diffConfig = OOUI\Element::configFromHtmlAttributes( 
$attribs );
                        $buttons['diff'] = new OOUI\ButtonInputWidget( [
@@ -4412,11 +4420,13 @@
                                'label' => $this->context->msg( 'showdiff' 
)->text(),
                                'infusable' => true,
                                'type' => 'submit',
+                               'title' => Linker::titleAttrib( 'diff' ),
+                               'accessKey' => Linker::accesskey( 'diff' ),
                        ] + $diffConfig );
                } else {
                        $buttons['diff'] = Html::submitButton(
                                $this->context->msg( 'showdiff' )->text(),
-                               $attribs + [ 'id' => 'wpDiff' ]
+                               $attribs + Linker::tooltipAndAccesskeyAttribs( 
'diff' ) + [ 'id' => 'wpDiff' ]
                        );
                }
 
diff --git a/includes/htmlform/HTMLFormField.php 
b/includes/htmlform/HTMLFormField.php
index 83a8023..7cb83e2 100644
--- a/includes/htmlform/HTMLFormField.php
+++ b/includes/htmlform/HTMLFormField.php
@@ -976,7 +976,7 @@
        }
 
        /**
-        * Returns the attributes required for the tooltip and accesskey.
+        * Returns the attributes required for the tooltip and accesskey, for 
Html::element() etc.
         *
         * @return array Attributes
         */
@@ -989,6 +989,22 @@
        }
 
        /**
+        * Returns the attributes required for the tooltip and accesskey, for 
OOUI widgets' config.
+        *
+        * @return array Attributes
+        */
+       public function getTooltipAndAccessKeyOOUI() {
+               if ( empty( $this->mParams['tooltip'] ) ) {
+                       return [];
+               }
+
+               return [
+                       'title' => Linker::titleAttrib( 
$this->mParams['tooltip'] ),
+                       'accessKey' => Linker::accesskey( 
$this->mParams['tooltip'] ),
+               ];
+       }
+
+       /**
         * Returns the given attributes from the parameters
         *
         * @param array $list List of attributes to get
diff --git a/includes/htmlform/OOUIHTMLForm.php 
b/includes/htmlform/OOUIHTMLForm.php
index ed99802..9dd37b3 100644
--- a/includes/htmlform/OOUIHTMLForm.php
+++ b/includes/htmlform/OOUIHTMLForm.php
@@ -66,7 +66,10 @@
                        }
 
                        if ( isset( $this->mSubmitTooltip ) ) {
-                               $attribs += Linker::tooltipAndAccesskeyAttribs( 
$this->mSubmitTooltip );
+                               $attribs += [
+                                       'title' => Linker::titleAttrib( 
$this->mSubmitTooltip ),
+                                       'accessKey' => Linker::accesskey( 
$this->mSubmitTooltip ),
+                               ];
                        }
 
                        $attribs['classes'] = [ 'mw-htmlform-submit' ];
diff --git a/includes/htmlform/fields/HTMLCheckField.php 
b/includes/htmlform/fields/HTMLCheckField.php
index b080e18..9a956fb 100644
--- a/includes/htmlform/fields/HTMLCheckField.php
+++ b/includes/htmlform/fields/HTMLCheckField.php
@@ -52,7 +52,7 @@
                        $value = !$value;
                }
 
-               $attr = $this->getTooltipAndAccessKey();
+               $attr = $this->getTooltipAndAccessKeyOOUI();
                $attr['id'] = $this->mID;
                $attr['name'] = $this->mName;
 
diff --git a/includes/htmlform/fields/HTMLMultiSelectField.php 
b/includes/htmlform/fields/HTMLMultiSelectField.php
index 2b6e066..0d5eeba 100644
--- a/includes/htmlform/fields/HTMLMultiSelectField.php
+++ b/includes/htmlform/fields/HTMLMultiSelectField.php
@@ -142,7 +142,7 @@
        public function getInputOOUI( $value ) {
                $this->mParent->getOutput()->addModules( 'oojs-ui-widgets' );
 
-               $attr = $this->getTooltipAndAccessKey();
+               $attr = [];
                $attr['id'] = $this->mID;
                $attr['name'] = "{$this->mName}[]";
 
diff --git a/includes/htmlform/fields/HTMLTextAreaField.php 
b/includes/htmlform/fields/HTMLTextAreaField.php
index 82ec3bf..480c5bb 100644
--- a/includes/htmlform/fields/HTMLTextAreaField.php
+++ b/includes/htmlform/fields/HTMLTextAreaField.php
@@ -71,7 +71,7 @@
                        throw new Exception( "OOUIHTMLForm does not support the 
'cols' parameter for textareas" );
                }
 
-               $attribs = $this->getTooltipAndAccessKey();
+               $attribs = $this->getTooltipAndAccessKeyOOUI();
 
                if ( $this->mClass !== '' ) {
                        $attribs['classes'] = [ $this->mClass ];
diff --git a/includes/htmlform/fields/HTMLTextField.php 
b/includes/htmlform/fields/HTMLTextField.php
index b0b66ca..1c5a43d 100644
--- a/includes/htmlform/fields/HTMLTextField.php
+++ b/includes/htmlform/fields/HTMLTextField.php
@@ -140,7 +140,7 @@
                        $value = '';
                }
 
-               $attribs = $this->getTooltipAndAccessKey();
+               $attribs = $this->getTooltipAndAccessKeyOOUI();
 
                if ( $this->mClass !== '' ) {
                        $attribs['classes'] = [ $this->mClass ];

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I63285b5bce3341875a6d82eba059623bf105ca62
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Bartosz Dziewoński <matma....@gmail.com>
Gerrit-Reviewer: Bartosz Dziewoński <matma....@gmail.com>
Gerrit-Reviewer: Florianschmidtwelzow <florian.schmidt.stargatewis...@gmail.com>
Gerrit-Reviewer: Jackmcbarn <jackmcb...@gmail.com>
Gerrit-Reviewer: Jforrester <jforres...@wikimedia.org>
Gerrit-Reviewer: Thiemo Mättig (WMDE) <thiemo.maet...@wikimedia.de>
Gerrit-Reviewer: Tpt <thoma...@hotmail.fr>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to