Skip to content

Issue-2909 header menu up/down key. #2988

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: qa-accessibility
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ exports[`Default render 1`] = `
onTouchStart={[Function]}
>
<span
onKeyDown={[Function]}
role="link"
tabIndex={0}
>
Expand All @@ -47,6 +48,7 @@ exports[`Default render 1`] = `
onTouchStart={[Function]}
>
<Link
onKeyDown={[Function]}
to="https://www.topcoder-dev.com/community/learn"
>
Tracks
Expand All @@ -60,6 +62,7 @@ exports[`Default render 1`] = `
onTouchStart={[Function]}
>
<span
onKeyDown={[Function]}
role="link"
tabIndex={0}
>
Expand Down Expand Up @@ -312,6 +315,7 @@ exports[`Render with open menu 1`] = `
onTouchStart={[Function]}
>
<span
onKeyDown={[Function]}
role="link"
tabIndex={0}
>
Expand All @@ -326,6 +330,7 @@ exports[`Render with open menu 1`] = `
onTouchStart={[Function]}
>
<Link
onKeyDown={[Function]}
to="https://www.topcoder-dev.com/community/learn"
>
Tracks
Expand All @@ -339,6 +344,7 @@ exports[`Render with open menu 1`] = `
onTouchStart={[Function]}
>
<span
onKeyDown={[Function]}
role="link"
tabIndex={0}
>
Expand Down Expand Up @@ -602,6 +608,7 @@ exports[`Render with specified profile 1`] = `
onTouchStart={[Function]}
>
<span
onKeyDown={[Function]}
role="link"
tabIndex={0}
>
Expand All @@ -616,6 +623,7 @@ exports[`Render with specified profile 1`] = `
onTouchStart={[Function]}
>
<Link
onKeyDown={[Function]}
to="https://www.topcoder-dev.com/community/learn"
>
Tracks
Expand All @@ -629,6 +637,7 @@ exports[`Render with specified profile 1`] = `
onTouchStart={[Function]}
>
<span
onKeyDown={[Function]}
role="link"
tabIndex={0}
>
Expand Down
13 changes: 11 additions & 2 deletions src/shared/components/TopcoderHeader/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,15 @@ export default class TopcoderHeader extends React.Component {
let styleName = 'main-menu-item';
if (openedMenu && openedMenu.title === item.title) styleName += ' opened';
if (item.title === currentNav.menuTitle) styleName += ' current';
const onMainMenuKeyDown = (event) => {
if (event.key === 'ArrowDown') {
event.preventDefault();
openMenu(item, event.target);
} else if (event.key === 'ArrowUp') {
event.preventDefault();
closeMenu();
}
};
return (
<li
key={item.title}
Expand All @@ -243,10 +252,10 @@ export default class TopcoderHeader extends React.Component {
styleName={styleName}
>
{item.url ? (
<Link to={item.url}>
<Link to={item.url} onKeyDown={onMainMenuKeyDown}>
{item.title}
</Link>
) : <span role="link" tabIndex={0}>{item.title}</span>}
) : <span role="link" tabIndex={0} onKeyDown={onMainMenuKeyDown}>{item.title}</span>}
</li>
);
});
Expand Down