Skip to content

Commit

Permalink
Accessibility insights fixes (#9955)
Browse files Browse the repository at this point in the history
* add aria-label to editor toggle, change the dropdown language selector to an option role rather than menuitem

* add role=menuitem to organization logo

* give editor selector div the role menuitem

* cloud sync status component is only visual. do not include an aria label on sui items that do not have a role or has a nullish role

* remove button role from outer div for projects header

* remove menu role from projectnamearea, give explicit role of button to save project button

* change other toolbar menus to menubars

* fixed capitalization on editortoggle aria label
  • Loading branch information
srietkerk authored Apr 10, 2024
1 parent b92e911 commit dd781e0
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions webapp/src/container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -525,12 +525,12 @@ export class EditorSelector extends data.Component<IEditorSelectorProps, {}> {
}

return (
<div id="editortoggle" className={`ui grid padded ${(pyOnly || tsOnly) ? "one-language" : ""}`} role="listbox" aria-orientation="horizontal">
<div id="editortoggle" className={`ui grid padded ${(pyOnly || tsOnly) ? "one-language" : ""}`} role="listbox" aria-orientation="horizontal" aria-label={lf("Editor toggle")}>
{showSandbox && <SandboxMenuItem parent={parent} />}
{showBlocks && <BlocksMenuItem parent={parent} />}
{textLanguage}
{secondTextLanguage}
{showDropdown && <sui.DropdownMenu id="editordropdown" role="menuitem" icon="chevron down" rightIcon title={lf("Select code editor language")} className={`item button attached right ${dropdownActive ? "active" : ""}`}>
{showDropdown && <sui.DropdownMenu id="editordropdown" role="option" icon="chevron down" rightIcon title={lf("Select code editor language")} className={`item button attached right ${dropdownActive ? "active" : ""}`}>
<JavascriptMenuItem parent={parent} />
<PythonMenuItem parent={parent} />
</sui.DropdownMenu>}
Expand Down
8 changes: 4 additions & 4 deletions webapp/src/editortoolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export class EditorToolbar extends data.Component<ISettingsProps, EditorToolbarS
readOnly={projectNameReadOnly}
/>)
if (showSave) {
saveInput.push(<EditorToolbarButton icon='save' className={`right attached editortools-btn save-editortools-btn ${saveButtonClasses}`} title={lf("Save")} ariaLabel={lf("Save the project")} onButtonClick={this.saveFile} view={this.getViewString(View.Computer)} key={`save${View.Computer}`} />)
saveInput.push(<EditorToolbarButton role="button" icon='save' className={`right attached editortools-btn save-editortools-btn ${saveButtonClasses}`} title={lf("Save")} ariaLabel={lf("Save the project")} onButtonClick={this.saveFile} view={this.getViewString(View.Computer)} key={`save${View.Computer}`} />)
}

return saveInput;
Expand Down Expand Up @@ -416,7 +416,7 @@ export class EditorToolbar extends data.Component<ISettingsProps, EditorToolbarS
}

return <div id="editortools" className="ui" role="region" aria-label={lf("Editor toolbar")}>
<div id="downloadArea" role="menu" className="ui column items">{headless &&
<div id="downloadArea" role="menubar" className="ui column items">{headless &&
<div className="ui item">
<div className="ui icon large buttons">
{compileBtn && <EditorToolbarButton icon={downloadIcon} className={`primary large download-button mobile tablet hide ${downloadButtonClasses}`} title={compileTooltip} onButtonClick={this.compile} view='computer' />}
Expand All @@ -431,14 +431,14 @@ export class EditorToolbar extends data.Component<ISettingsProps, EditorToolbarS
</div>}
</div>
{(showProjectRename || showGithub || identity.CloudSaveStatus.wouldRender(header.id)) &&
<div id="projectNameArea" role="menu" className="ui column items">
<div id="projectNameArea" className="ui column items">
<div className={`ui right ${showSave ? "labeled" : ""} input projectname-input projectname-computer`}>
{showProjectRename && this.getSaveInput(showSave, "fileNameInput2", projectName, showProjectRenameReadonly)}
{showGithub && <githubbutton.GithubButton parent={this.props.parent} key={`githubbtn${computer}`} />}
<identity.CloudSaveStatus headerId={header.id} />
</div>
</div>}
<div id="editorToolbarArea" role="menu" className="ui column items">
<div id="editorToolbarArea" role="menubar" className="ui column items">
{showUndoRedo && <div className="ui icon buttons">{this.getUndoRedo(computer)}</div>}
{showZoomControls && <div className="ui icon buttons mobile hide">{this.getZoomControl(computer)}</div>}
{targetTheme.bigRunButton && !pxt.shell.isTimeMachineEmbed() &&
Expand Down
4 changes: 2 additions & 2 deletions webapp/src/headerbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export class HeaderBar extends data.Component<ISettingsProps, {}> {
if (view === "time-machine") {
return <></>;
}
return <div className="ui item logo organization">
return <div className="ui item logo organization" role="menuitem">
{targetTheme.organizationWideLogo || targetTheme.organizationLogo
? <img className={`ui logo ${view !== "home" ? "mobile hide" : ""}`} src={targetTheme.organizationWideLogo || targetTheme.organizationLogo} alt={lf("{0} Logo", targetTheme.organization)} />
: <span className="name">{targetTheme.organization}</span>}
Expand Down Expand Up @@ -178,7 +178,7 @@ export class HeaderBar extends data.Component<ISettingsProps, {}> {
break;
}
} else {
return <div className="ui item link editor-menuitem">
return <div className="ui item link editor-menuitem" role="menuitem">
<container.EditorSelector parent={this.props.parent} sandbox={view === "sandbox"} python={targetTheme.python} languageRestriction={languageRestriction} headless={pxt.appTarget.simulator?.headless} />
</div>
}
Expand Down
4 changes: 2 additions & 2 deletions webapp/src/identity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ export class CloudSaveStatus extends data.Component<CloudSaveStatusProps, {}> {
const syncing = preparing || cloudStatus.value === "syncing";

return (<div className="cloudstatusarea">
{!syncing && <sui.Item className={"ui tiny cloudicon xicon " + cloudStatus.icon} title={cloudStatus.tooltip} tabIndex={-1}></sui.Item>}
{syncing && <sui.Item className={"ui tiny inline loader active cloudprogress" + (preparing ? " indeterminate" : "")} title={cloudStatus.tooltip} tabIndex={-1}></sui.Item>}
{!syncing && <sui.Item role="presentation" className={"ui tiny cloudicon xicon " + cloudStatus.icon} title={cloudStatus.tooltip} tabIndex={-1}></sui.Item>}
{syncing && <sui.Item role="presentation" className={"ui tiny inline loader active cloudprogress" + (preparing ? " indeterminate" : "")} title={cloudStatus.tooltip} tabIndex={-1}></sui.Item>}
{cloudStatus.value !== "none" && cloudStatus.value !== "synced" && <span className="ui mobile hide no-select cloudtext" role="note">{cloudStatus.shortStatus}</span>}
</div>);
}
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/projects.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export class Projects extends auth.Component<ISettingsProps, ProjectsState> {
<div key={`mystuff_gallerysegment`} className="ui segment gallerysegment mystuff-segment" role="region" aria-label={lf("My Projects")}>
<div className="ui heading">
<div className="column" style={{ zIndex: 1 }}
role={scriptManager && "button"} onClick={scriptManager && this.showScriptManager} onKeyDown={scriptManager && fireClickOnEnter}
onClick={scriptManager && this.showScriptManager} onKeyDown={scriptManager && fireClickOnEnter}
>
{scriptManager ? <h2 className="ui header myproject-header">
{lf("My Projects")}
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/sui.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ export class Item extends data.Component<ItemProps, {}> {
return (
<div className={genericClassName("ui item link", this.props, true) + ` ${this.props.active ? 'active' : ''}`}
role={this.props.role}
aria-label={ariaLabel || title || text}
aria-label={(!this.props.role || this.props.role === "presentation") ? "" : ariaLabel || title || text}
aria-selected={this.props.active}
aria-hidden={ariaHidden}
title={title || text}
Expand Down

0 comments on commit dd781e0

Please sign in to comment.