Skip to content

Commit 55b4f73

Browse files
srietkerkCopilot
andauthored
Fix accessibility of logos in main menubar (#11066)
* logos in top bar are aria hidden when uninteractive and buttons and a menuitem when interactive * remove redundant styling Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * make the image based logos also buttons --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 080a552 commit 55b4f73

2 files changed

Lines changed: 45 additions & 8 deletions

File tree

theme/common.less

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,11 @@ div.simframe > iframe {
604604
margin-bottom: 1px;
605605
}
606606

607+
.ui.item.logo button.name,
608+
.ui.item.logo button.name-short {
609+
margin-left: 0 !important;
610+
}
611+
607612
.ui.item.logo .name-short {
608613
display: none;
609614
}
@@ -618,6 +623,13 @@ div.simframe > iframe {
618623
height: 1.4rem;
619624
}
620625

626+
.ui.item.logo .logo-button {
627+
img {
628+
margin: 3px 0 0 0 !important;
629+
}
630+
}
631+
632+
621633
/* Native Host (iOS app) back button */
622634
.nativeback.ui.item {
623635
margin-right: -1rem;

webapp/src/headerbar.tsx

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import * as tutorial from "./tutorial";
1414

1515
import ISettingsProps = pxt.editor.ISettingsProps;
1616
import { ThemeManager } from "../../react-common/components/theming/themeManager";
17+
import { Button } from "../../react-common/components/controls/Button";
1718

1819
type HeaderBarView = "home" | "editor" | "tutorial" | "tutorial-tab" | "debugging" | "sandbox" | "time-machine";
1920
const LONGPRESS_DURATION = 750;
@@ -107,7 +108,7 @@ export class HeaderBar extends data.Component<ISettingsProps, {}> {
107108
return <></>;
108109
}
109110

110-
return <div className="ui item logo organization" role="presentation">
111+
return <div className="ui item logo organization" aria-hidden="true">
111112
{targetTheme.organizationWideLogo || targetTheme.organizationLogo
112113
? <img className={`ui logo ${view !== "home" ? "mobile hide" : ""}`} src={targetTheme.organizationWideLogo || targetTheme.organizationLogo} alt={lf("{0} Logo", targetTheme.organization)} />
113114
: <span className="name">{targetTheme.organization}</span>}
@@ -123,16 +124,40 @@ export class HeaderBar extends data.Component<ISettingsProps, {}> {
123124
const shouldLinkHome = pxt.shell.hasHomeScreen() && view !== "home";
124125

125126
const role = shouldLinkHome ? "menuitem" : "presentation";
126-
const onClickHandler = shouldLinkHome ? this.brandIconClick : undefined;
127127

128128
// TODO: "sandbox" view components are temporary share page layout
129-
return <div aria-label={lf("{0} Logo", targetTheme.boardName)} role={role} className={`ui item logo brand ${view !== "sandbox" && view !== "home" ? "mobile hide" : ""}`} onClick={onClickHandler}>
129+
return <div aria-hidden={!shouldLinkHome} role={role} className={`ui item logo brand ${view !== "sandbox" && view !== "home" ? "mobile hide" : ""}`}>
130130
{targetTheme.useTextLogo
131-
? [ <span className="name" key="org-name">{targetTheme.organizationText}</span>,
132-
<span className="name-short" key="org-name-short">{targetTheme.organizationShortText || targetTheme.organizationText}</span> ]
133-
: (targetTheme.logo || targetTheme.portraitLogo
134-
? <img className={`ui ${targetTheme.logoWide ? "small" : ""} logo`} src={targetTheme.logo || targetTheme.portraitLogo} alt={lf("{0} Logo", targetTheme.boardName)} />
135-
: <span className="name">{targetTheme.boardName}</span>)}
131+
? (shouldLinkHome
132+
? [<Button className="name menu-button" key="org-name"
133+
onClick={this.brandIconClick}
134+
title={lf("MakeCode {0} Logo, return to home page", targetTheme.boardName)}
135+
ariaLabel={lf("MakeCode {0} Logo, return to home page", targetTheme.boardName)}
136+
label={targetTheme.organizationText} />,
137+
<Button className="name-short menu-button" key="org-name-short"
138+
onClick={this.brandIconClick}
139+
title={lf("MakeCode {0} Logo, return to home page", targetTheme.boardName)}
140+
ariaLabel={lf("MakeCode {0} Logo, return to home page", targetTheme.boardName)}
141+
label={targetTheme.organizationShortText || targetTheme.organizationText} />]
142+
: [ <span className="name" key="org-name">{targetTheme.organizationText}</span>,
143+
<span className="name-short" key="org-name-short">{targetTheme.organizationShortText || targetTheme.organizationText}</span> ])
144+
: (shouldLinkHome
145+
? (targetTheme.logo || targetTheme.portraitLogo
146+
? <Button className="logo-button menu-button"
147+
onClick={this.brandIconClick}
148+
title={lf("MakeCode {0} Logo, return to home page", targetTheme.boardName)}
149+
ariaLabel={lf("MakeCode {0} Logo, return to home page", targetTheme.boardName)}
150+
>
151+
<img className={`ui ${targetTheme.logoWide ? "small" : ""} logo`} src={targetTheme.logo || targetTheme.portraitLogo} alt={lf("{0} Logo", targetTheme.boardName)} />
152+
</Button>
153+
: <Button className="name menu-button"
154+
onClick={this.brandIconClick}
155+
title={lf("MakeCode {0} Logo, return to home page", targetTheme.boardName)}
156+
ariaLabel={lf("MakeCode {0} Logo, return to home page", targetTheme.boardName)}
157+
label={targetTheme.boardName} />)
158+
: (targetTheme.logo || targetTheme.portraitLogo
159+
? <img className={`ui ${targetTheme.logoWide ? "small" : ""} logo`} src={targetTheme.logo || targetTheme.portraitLogo} alt={lf("{0} Logo", targetTheme.boardName)} />
160+
: <span className="name">{targetTheme.boardName}</span>))}
136161
</div>
137162
}
138163

0 commit comments

Comments
 (0)