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
'tabindex' => 1,
'size' => 60,
'spellcheck' => 'true',
'tabindex' => 1,
'size' => 60,
'spellcheck' => 'true',
- ] + Linker::tooltipAndAccesskeyAttribs( 'summary' );
$inputAttrs = null, $spanLabelAttrs = null
) {
$inputAttrs = $this->getSummaryInputAttributes( $inputAttrs );
$inputAttrs = null, $spanLabelAttrs = null
) {
$inputAttrs = $this->getSummaryInputAttributes( $inputAttrs );
+ $inputAttrs += Linker::tooltipAndAccesskeyAttribs( 'summary' );
$spanLabelAttrs = ( is_array( $spanLabelAttrs ) ? $spanLabelAttrs : [] ) + [
'class' => $this->missingSummary ? 'mw-summarymissed' : 'mw-summary',
$spanLabelAttrs = ( is_array( $spanLabelAttrs ) ? $spanLabelAttrs : [] ) + [
'class' => $this->missingSummary ? 'mw-summarymissed' : 'mw-summary',
$inputAttrs = OOUI\Element::configFromHtmlAttributes(
$this->getSummaryInputAttributes( $inputAttrs )
);
$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'];
// For compatibility with old scripts and extensions, we want the legacy 'id' on the `<input>`
$inputAttrs['inputId'] = $inputAttrs['id'];
$accesskey = null;
if ( isset( $options['tooltip'] ) ) {
$accesskey = $this->context->msg( "accesskey-{$options['tooltip']}" )->text();
$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();
}
if ( isset( $options['title-message'] ) ) {
$title = $this->context->msg( $options['title-message'] )->text();
$attribs = [
'name' => 'wpSave',
'tabindex' => ++$tabindex,
$attribs = [
'name' => 'wpSave',
'tabindex' => ++$tabindex,
- ] + Linker::tooltipAndAccesskeyAttribs( 'save' );
-
if ( $this->oouiEnabled ) {
$saveConfig = OOUI\Element::configFromHtmlAttributes( $attribs );
$buttons['save'] = new OOUI\ButtonInputWidget( [
if ( $this->oouiEnabled ) {
$saveConfig = OOUI\Element::configFromHtmlAttributes( $attribs );
$buttons['save'] = new OOUI\ButtonInputWidget( [
'label' => $buttonLabel,
'infusable' => true,
'type' => 'submit',
'label' => $buttonLabel,
'infusable' => true,
'type' => 'submit',
+ 'title' => Linker::titleAttrib( 'save' ),
+ 'accessKey' => Linker::accesskey( 'save' ),
] + $saveConfig );
} else {
$buttons['save'] = Html::submitButton(
$buttonLabel,
] + $saveConfig );
} else {
$buttons['save'] = Html::submitButton(
$buttonLabel,
- $attribs + [ 'id' => 'wpSave' ],
+ $attribs + Linker::tooltipAndAccesskeyAttribs( 'save' ) + [ 'id' => 'wpSave' ],
[ 'mw-ui-progressive' ]
);
}
[ 'mw-ui-progressive' ]
);
}
$attribs = [
'name' => 'wpPreview',
'tabindex' => ++$tabindex,
$attribs = [
'name' => 'wpPreview',
'tabindex' => ++$tabindex,
- ] + Linker::tooltipAndAccesskeyAttribs( 'preview' );
if ( $this->oouiEnabled ) {
$previewConfig = OOUI\Element::configFromHtmlAttributes( $attribs );
$buttons['preview'] = new OOUI\ButtonInputWidget( [
if ( $this->oouiEnabled ) {
$previewConfig = OOUI\Element::configFromHtmlAttributes( $attribs );
$buttons['preview'] = new OOUI\ButtonInputWidget( [
'useInputTag' => true,
'label' => $this->context->msg( 'showpreview' )->text(),
'infusable' => true,
'useInputTag' => true,
'label' => $this->context->msg( 'showpreview' )->text(),
'infusable' => true,
+ 'type' => 'submit',
+ 'title' => Linker::titleAttrib( 'preview' ),
+ 'accessKey' => Linker::accesskey( 'preview' ),
] + $previewConfig );
} else {
$buttons['preview'] = Html::submitButton(
$this->context->msg( 'showpreview' )->text(),
] + $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,
);
}
$attribs = [
'name' => 'wpDiff',
'tabindex' => ++$tabindex,
- ] + Linker::tooltipAndAccesskeyAttribs( 'diff' );
if ( $this->oouiEnabled ) {
$diffConfig = OOUI\Element::configFromHtmlAttributes( $attribs );
$buttons['diff'] = new OOUI\ButtonInputWidget( [
if ( $this->oouiEnabled ) {
$diffConfig = OOUI\Element::configFromHtmlAttributes( $attribs );
$buttons['diff'] = new OOUI\ButtonInputWidget( [
'label' => $this->context->msg( 'showdiff' )->text(),
'infusable' => true,
'type' => 'submit',
'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(),
] + $diffConfig );
} else {
$buttons['diff'] = Html::submitButton(
$this->context->msg( 'showdiff' )->text(),
- $attribs + [ 'id' => 'wpDiff' ]
+ $attribs + Linker::tooltipAndAccesskeyAttribs( 'diff' ) + [ 'id' => 'wpDiff' ]
- * 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
*/
*
* @return array Attributes
*/
return Linker::tooltipAndAccesskeyAttribs( $this->mParams['tooltip'] );
}
return Linker::tooltipAndAccesskeyAttribs( $this->mParams['tooltip'] );
}
+ /**
+ * 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
*
/**
* Returns the given attributes from the parameters
*
}
if ( isset( $this->mSubmitTooltip ) ) {
}
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' ];
}
$attribs['classes'] = [ 'mw-htmlform-submit' ];
- $attr = $this->getTooltipAndAccessKey();
+ $attr = $this->getTooltipAndAccessKeyOOUI();
$attr['id'] = $this->mID;
$attr['name'] = $this->mName;
$attr['id'] = $this->mID;
$attr['name'] = $this->mName;
public function getInputOOUI( $value ) {
$this->mParent->getOutput()->addModules( 'oojs-ui-widgets' );
public function getInputOOUI( $value ) {
$this->mParent->getOutput()->addModules( 'oojs-ui-widgets' );
- $attr = $this->getTooltipAndAccessKey();
$attr['id'] = $this->mID;
$attr['name'] = "{$this->mName}[]";
$attr['id'] = $this->mID;
$attr['name'] = "{$this->mName}[]";
throw new Exception( "OOUIHTMLForm does not support the 'cols' parameter for textareas" );
}
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 ];
if ( $this->mClass !== '' ) {
$attribs['classes'] = [ $this->mClass ];
- $attribs = $this->getTooltipAndAccessKey();
+ $attribs = $this->getTooltipAndAccessKeyOOUI();
if ( $this->mClass !== '' ) {
$attribs['classes'] = [ $this->mClass ];
if ( $this->mClass !== '' ) {
$attribs['classes'] = [ $this->mClass ];