Fomafix has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/372352 )

Change subject: Avoid href="#" for <a>
......................................................................

Avoid href="#" for <a>

The href="#" shows a status line and allows to open a new tab on
middle click.

Add tabindex="0" and role="button" instead to still allow to focus the
element with the keyboard.

Add JavaScript event handler for the return key of the keyboard to
still allow to trigger the event with the keyboard.

Change-Id: I014303bb7ea753b0dfc2efa83120ad0b7a50f2cf
---
M CleanChanges_body.php
M resources/cleanchanges.js
2 files changed, 18 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CleanChanges 
refs/changes/52/372352/1

diff --git a/CleanChanges_body.php b/CleanChanges_body.php
index 6a0e505..76c562e 100644
--- a/CleanChanges_body.php
+++ b/CleanChanges_body.php
@@ -289,7 +289,8 @@
                        'data-mw-cleanchanges-level' => $rci,
                        'data-mw-cleanchanges-other' => $rcm,
                        'data-mw-cleanchanges-link' => $rcl,
-                       'href' => '#',
+                       'tabindex' => '0',
+                       'role' => 'button',
                        'class' => 'mw-cleanchanges-showblock'
                ];
                $tl =
@@ -567,7 +568,8 @@
                $rcl = 'RCUL' . $linkindex;
                $rcm = 'RCUM' . $linkindex;
                $linkAttribs = [
-                       'href' => '#',
+                       'tabindex' => '0',
+                       'role' => 'button',
                        'class' => 'mw-cleanchanges-showuserinfo',
                        'data-mw-userinfo-id' => $rci,
                        'data-mw-userinfo-target' => $rcl
diff --git a/resources/cleanchanges.js b/resources/cleanchanges.js
index 299d336..6775572 100644
--- a/resources/cleanchanges.js
+++ b/resources/cleanchanges.js
@@ -29,9 +29,13 @@
                        id = $this.data( 'mw-userinfo-id' );
                        target = $this.data( 'mw-userinfo-target' );
                        if ( id !== undefined ) {
-                               $this.click( function ( e ) {
-                                       e.preventDefault();
-                                       window.showUserInfo( 'wgUserInfo' + id, 
target );
+                               $this.on( 'click keypress', function ( e ) {
+                                       if (
+                                               e.type === 'click' ||
+                                               e.type === 'keypress' && 
e.which === 13
+                                       ) {
+                                               window.showUserInfo( 
'wgUserInfo' + id, target );
+                                       }
                                } );
                        }
                } );
@@ -43,9 +47,13 @@
                        other = $this.data( 'mw-cleanchanges-other' );
                        link = $this.data( 'mw-cleanchanges-link' );
                        if ( level !== undefined ) {
-                               $this.click( function ( e ) {
-                                       e.preventDefault();
-                                       window.toggleVisibilityE( level, other, 
link, 'block' );
+                               $this.on( 'click keypress', function ( e ) {
+                                       if (
+                                               e.type === 'click' ||
+                                               e.type === 'keypress' && 
e.which === 13
+                                       ) {
+                                               window.toggleVisibilityE( 
level, other, link, 'block' );
+                                       }
                                } );
                        }
                } );

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I014303bb7ea753b0dfc2efa83120ad0b7a50f2cf
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CleanChanges
Gerrit-Branch: master
Gerrit-Owner: Fomafix <[email protected]>

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

Reply via email to