]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-16703 [891726] Function cannot be performed by keyboard alone
authorWouter Admiraal <wouter.admiraal@sonarsource.com>
Wed, 10 Aug 2022 12:30:51 +0000 (14:30 +0200)
committersonartech <sonartech@sonarsource.com>
Thu, 11 Aug 2022 20:03:49 +0000 (20:03 +0000)
server/sonar-web/src/main/js/app/components/nav/component/Menu.css
server/sonar-web/src/main/js/app/components/nav/component/Menu.tsx
server/sonar-web/src/main/js/components/ui/NavBarTabs.css

index 5e891d3064930c4e5ef5d5d2646fb01381f15525..2602439afa4551f043db92461820e53909003efc 100644 (file)
  * along with this program; if not, write to the Free Software Foundation,
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
-.navbar-tabs > li > a.menu-button {
-  color: var(--darkBlue);
+.navbar-tabs > li > .menu-button {
+  color: var(--darkBlue) !important;
 }
 
-.navbar-tabs > li > a.menu-button:hover {
-  color: var(--blue);
-  border-bottom-color: transparent;
+.navbar-tabs > li > .menu-button:hover {
+  color: var(--blue) !important;
+  border-bottom-color: transparent !important;
 }
 
-.navbar-tabs > li > a.disabled-link,
-.navbar-tabs > li > a.disabled-link:hover {
+.navbar-tabs > li > .disabled-link,
+.navbar-tabs > li > .disabled-link:hover {
   color: var(--gray71);
   cursor: default;
   border-bottom-color: transparent;
index 48cef3e147068f7ccda24f39bd76bd8843e2dd24..a01609d78a84279727dfbcfc613b59043bcddaab 100644 (file)
@@ -20,6 +20,7 @@
 import classNames from 'classnames';
 import * as React from 'react';
 import { NavLink } from 'react-router-dom';
+import { ButtonLink } from '../../../../components/controls/buttons';
 import Dropdown from '../../../../components/controls/Dropdown';
 import Tooltip from '../../../../components/controls/Tooltip';
 import BulletListIcon from '../../../../components/icons/BulletListIcon';
@@ -65,15 +66,15 @@ interface Props {
 type Query = BranchParameters & { id: string };
 
 export class Menu extends React.PureComponent<Props> {
-  projectInfoLink = React.createRef<HTMLAnchorElement>();
+  projectInfoLink: HTMLElement | null = null;
 
   componentDidUpdate(prevProps: Props) {
     if (
       prevProps.projectInfoDisplayed &&
       !this.props.projectInfoDisplayed &&
-      this.projectInfoLink.current
+      this.projectInfoLink
     ) {
-      this.projectInfoLink.current.focus();
+      this.projectInfoLink.focus();
     }
   }
 
@@ -302,19 +303,17 @@ export class Menu extends React.PureComponent<Props> {
         overlay={<ul className="menu">{adminLinks}</ul>}
         tagName="li">
         {({ onToggleClick, open }) => (
-          <a
+          <ButtonLink
             aria-expanded={open}
             aria-haspopup="menu"
-            role="button"
             className={classNames('dropdown-toggle', { active: isSettingsActive || open })}
-            href="#"
             id="component-navigation-admin"
             onClick={onToggleClick}>
             {hasMessage('layout.settings', component.qualifier)
               ? translate('layout.settings', component.qualifier)
               : translate('layout.settings')}
             <DropdownIcon className="little-spacer-left" />
-          </a>
+          </ButtonLink>
         )}
       </Dropdown>
     );
@@ -360,20 +359,15 @@ export class Menu extends React.PureComponent<Props> {
     return (
       (isProject || isApplication) && (
         <li>
-          <a
+          <ButtonLink
             className="menu-button"
-            onClick={(e: React.SyntheticEvent<HTMLAnchorElement>) => {
-              e.preventDefault();
-              e.currentTarget.blur();
-              this.props.onToggleProjectInfo();
-            }}
-            href="#"
-            role="button"
-            tabIndex={0}
-            ref={this.projectInfoLink}>
+            onClick={this.props.onToggleProjectInfo}
+            innerRef={node => {
+              this.projectInfoLink = node;
+            }}>
             <BulletListIcon className="little-spacer-right" />
             {label}
-          </a>
+          </ButtonLink>
         </li>
       )
     );
@@ -610,17 +604,15 @@ export class Menu extends React.PureComponent<Props> {
         }
         tagName="li">
         {({ onToggleClick, open }) => (
-          <a
+          <ButtonLink
             aria-expanded={open}
             aria-haspopup="menu"
-            role="button"
             className={classNames('dropdown-toggle', { active: open })}
-            href="#"
             id="component-navigation-more"
             onClick={onToggleClick}>
             {translate('more')}
             <DropdownIcon className="little-spacer-left" />
-          </a>
+          </ButtonLink>
         )}
       </Dropdown>
     );
index 49bceb0df470c16817eb9613f7bcf603f2d6f9b5..91e00f53a16a73aca4df4e7bad3d0a193e8cd722 100644 (file)
@@ -29,7 +29,8 @@
   margin-left: 20px;
 }
 
-.navbar-tabs > li > a {
+.navbar-tabs > li > a,
+.navbar-tabs > li > button.button-link {
   display: block;
   height: var(--controlHeight);
   line-height: 16px;
@@ -42,6 +43,9 @@
 
 .navbar-tabs > li > a.active,
 .navbar-tabs > li > a:hover,
-.navbar-tabs > li > a:focus {
+.navbar-tabs > li > a:focus,
+.navbar-tabs > li > button.button-link.active,
+.navbar-tabs > li > button.button-link:hover,
+.navbar-tabs > li > button.button-link:focus {
   border-bottom-color: var(--blue);
 }