Skip to content
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

a11y: add labeled aria regions to pages #3259

Merged
merged 5 commits into from
Jun 1, 2020
Merged
Show file tree
Hide file tree
Changes from 4 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
5 changes: 3 additions & 2 deletions Composer/packages/client/src/components/NavTree/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ export interface INavTreeItem {

interface INavTreeProps {
navLinks: INavTreeItem[];
regionName: string;
}

const NavTree: React.FC<INavTreeProps> = (props) => {
const { navLinks } = props;
const { navLinks, regionName } = props;
const {
actions: { updateUserSettings },
state: {
Expand All @@ -46,7 +47,7 @@ const NavTree: React.FC<INavTreeProps> = (props) => {
size={{ width: currentWidth, height: 'auto' }}
onResizeStop={handleResize}
>
<div className="ProjectTree" css={root} data-testid="ProjectTree">
<div aria-label={regionName} className="ProjectTree" css={root} data-testid="ProjectTree" role="region">
{navLinks.map((item) => {
const isSelected = location.pathname.includes(item.url);

Expand Down
8 changes: 5 additions & 3 deletions Composer/packages/client/src/components/Page/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ interface IPageProps {
toolbarItems: any;
navLinks: INavTreeItem[];
title: string;
navRegionName: string;
mainRegionName: string;
onRenderHeaderContent?: () => string | JSX.Element | null;
'data-testid'?: string;
}

const Page: React.FC<IPageProps> = (props) => {
const { title, navLinks, toolbarItems, onRenderHeaderContent, children } = props;
const { title, navLinks, toolbarItems, onRenderHeaderContent, children, navRegionName, mainRegionName } = props;

return (
<div css={styles.root} data-testid={props['data-testid']}>
Expand All @@ -31,8 +33,8 @@ const Page: React.FC<IPageProps> = (props) => {
{onRenderHeaderContent && <div css={styles.headerContent}>{onRenderHeaderContent()}</div>}
</div>
<div css={styles.main} role="main">
<NavTree navLinks={navLinks} />
<div css={styles.content} data-testid="PageContent">
<NavTree navLinks={navLinks} regionName={navRegionName} />
<div aria-label={mainRegionName} css={styles.content} data-testid="PageContent" role="region">
{children}
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const Pagination: React.FC<IPaginationProps> = (props) => {
};

return (
<div css={container}>
<div aria-label={formatMessage('navigation control')} css={container} role="region">
<DefaultButton allowDisabledFocus disabled={index === 0} text="< Previous" onClick={hanglePreviousClick} />
<span css={text}>Page</span>
<Dropdown
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,13 @@ export const ProjectTree: React.FC<IProjectTreeProps> = (props) => {
size={{ width: currentWidth, height: 'auto' }}
onResizeStop={handleResize}
>
<div className="ProjectTree" css={root} data-testid="ProjectTree">
<div
aria-label={formatMessage('Navigation pane')}
className="ProjectTree"
css={root}
data-testid="ProjectTree"
role="region"
>
<FocusZone isCircularNavigation direction={FocusZoneDirection.vertical}>
<SearchBox
underlined
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export function ToolBar(props) {
}, []);

return (
<div css={headerSub} {...rest}>
<div aria-label={formatMessage('toolbar')} css={headerSub} role="region" {...rest}>
<div css={leftActions}>
{window.location.href.indexOf('/dialogs/') !== -1 && (
<div ref={addNewRef}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ const PropertyEditor: React.FC = () => {
size={{ width: currentWidth, height: 'auto' }}
onResizeStop={handleResize}
>
<div aria-label={formatMessage('form editor')} css={formEditor} data-testid="PropertyEditor">
<div aria-label={formatMessage('form editor')} css={formEditor} data-testid="PropertyEditor" role="region">
<Extension plugins={plugins} shell={shellApi} shellData={shellData}>
<AdaptiveForm
errors={errors}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const VisualEditor: React.FC<VisualEditorProps> = (props) => {
<React.Fragment>
<div
ref={addRef}
aria-label={formatMessage('visual editor')}
aria-label={formatMessage('Visual editor')}
css={visualEditor(triggerButtonVisible || !selected)}
data-testid="VisualEditor"
>
Expand Down
2 changes: 1 addition & 1 deletion Composer/packages/client/src/pages/design/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ const DesignPage: React.FC<RouteComponentProps<{ dialogId: string; projectId: st
/>
<Conversation css={editorContainer}>
<div css={editorWrapper}>
<div css={visualPanel}>
<div aria-label={formatMessage('Authoring canvas')} css={visualPanel} role="region">
{breadcrumbItems}
{dialogJsonVisible ? (
<JsonEditor
Expand Down
4 changes: 3 additions & 1 deletion Composer/packages/client/src/pages/home/ItemContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ interface ItemContainerProps extends Omit<IButtonProps, 'onChange' | 'styles' |
disabled?: boolean;
forwardedRef?: (project: any) => void | Promise<void>;
openExternal?: boolean;
ariaLabel: string;
}

export const ItemContainer: React.FC<ItemContainerProps> = ({
Expand All @@ -42,11 +43,12 @@ export const ItemContainer: React.FC<ItemContainerProps> = ({
disabled,
forwardedRef,
openExternal,
ariaLabel,
...rest
}) => {
const onRenderChildren = () => {
return (
<div ref={forwardedRef} css={childrenContainer}>
<div ref={forwardedRef} aria-label={ariaLabel} css={childrenContainer}>
<div css={[itemContainer, styles.title, disabled ? disabledItem.title : undefined]}>
<div css={itemContainerTitle}>
<Text block variant="large">
Expand Down
12 changes: 8 additions & 4 deletions Composer/packages/client/src/pages/home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const linksButtom = [
},
];

const turtorials = [
const tutorials = [
{
title: formatMessage('5 Minute Intro'),
content: formatMessage('Chris Whitten'),
Expand Down Expand Up @@ -145,14 +145,15 @@ const Home: React.FC<RouteComponentProps> = () => {
<div css={home.page}>
<div css={home.leftPage} role="main">
<h1 css={home.title}>{formatMessage(`Bot Framework Composer`)}</h1>
<div css={home.introduction}>
<div aria-label={formatMessage('Composer introduction')} css={home.introduction} role="region">
{formatMessage(
'Bot Framework Composer is an integrated development environment (IDE) for building bots and other types of conversational software with the Microsoft Bot Framework technology stack'
)}
</div>
<div css={home.newBotContainer}>
<div data-testid={'homePage-body-New'}>
<ItemContainer
ariaLabel={formatMessage('Create new empty bot')}
content={formatMessage('New')}
styles={home.newBotItem}
title={addButton}
Expand All @@ -164,6 +165,7 @@ const Home: React.FC<RouteComponentProps> = () => {
</div>
{recentProjects.length > 0 ? (
<ItemContainer
ariaLabel={recentProjects[0].name}
content={recentProjects[0].name}
forwardedRef={addRef}
styles={home.latestBotItem}
Expand All @@ -174,6 +176,7 @@ const Home: React.FC<RouteComponentProps> = () => {
/>
) : (
<ItemContainer
ariaLabel={'ToDo bot with LUIS'}
content={'ToDoBotWithLuis'}
forwardedRef={addRef}
styles={home.latestBotItem}
Expand All @@ -198,9 +201,10 @@ const Home: React.FC<RouteComponentProps> = () => {
<div css={home.leftContainer}>
<h2 css={home.subtitle}>{formatMessage('Video tutorials:')}&nbsp;</h2>
<div css={home.newBotContainer}>
{turtorials.map((item, index) => (
{tutorials.map((item, index) => (
<ItemContainer
key={index}
ariaLabel={item.title}
content={item.content}
href={item.href}
openExternal={isElectron()}
Expand Down Expand Up @@ -235,7 +239,7 @@ const Home: React.FC<RouteComponentProps> = () => {
</div>
</div>
</div>
<div css={home.rightPage}>
<div aria-label={formatMessage('Example bot list')} css={home.rightPage} role="region">
<h3 css={home.bluetitle}>{formatMessage(`Examples`)}</h3>
<p css={home.examplesDescription}>
{formatMessage(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ const LGPage: React.FC<LGPageProps> = (props) => {
return (
<Page
data-testid="LGPage"
mainRegionName={formatMessage('LG editor')}
navLinks={navLinks}
navRegionName={formatMessage('LG Navigation Pane')}
title={formatMessage('Bot Responses')}
toolbarItems={toolbarItems}
onRenderHeaderContent={onRenderHeaderContent}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ const LUPage: React.FC<LUPageProps> = (props) => {
return (
<Page
data-testid="LUPage"
mainRegionName={formatMessage('LU editor')}
navLinks={navLinks}
navRegionName={formatMessage('LU Navigation Pane')}
title={formatMessage('User Input')}
toolbarItems={toolbarItems}
onRenderHeaderContent={onRenderHeaderContent}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export const NotificationList: React.FC<INotificationListProps> = (props) => {

return (
<div css={listRoot} data-testid="notifications-table-view" role="main">
<div css={tableView}>
<div aria-label={formatMessage('Notification list')} css={tableView} role="region">
<ScrollablePane scrollbarVisibility={ScrollbarVisibility.auto}>
<DetailsList
isHeaderVisible
Expand Down
6 changes: 3 additions & 3 deletions Composer/packages/client/src/pages/publish/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const Publish: React.FC<PublishPageProps> = (props) => {
const [publishDialogHidden, setPublishDialogHidden] = useState(true);

// items to show in the list
const [thisPublishHistory, setThisPublishHistory] = useState<any[]>([]);
const [thisPublishHistory, setThisPublishHistory] = useState<IStatus[]>([]);
const [groups, setGroups] = useState<any[]>([]);
const [selectedVersion, setSelectedVersion] = useState<IStatus | null>(null);
const [dialogProps, setDialogProps] = useState({
Expand Down Expand Up @@ -403,7 +403,7 @@ const Publish: React.FC<PublishPageProps> = (props) => {
<h1 css={HeaderText}>{selectedTarget ? selectedTargetName : formatMessage('Publish Profiles')}</h1>
</div>
<div css={ContentStyle} data-testid="Publish" role="main">
<div css={projectContainer}>
<div aria-label={formatMessage('Navigation panel')} css={projectContainer} role="region">
<div
key={'_all'}
css={selectedTargetName === 'all' ? targetSelected : overflowSet}
Expand Down Expand Up @@ -431,7 +431,7 @@ const Publish: React.FC<PublishPageProps> = (props) => {
/>
)}
</div>
<div css={contentEditor}>
<div aria-label={formatMessage('List view')} css={contentEditor} role="region">
<Fragment>
<PublishStatusList
groups={groups}
Expand Down
8 changes: 7 additions & 1 deletion Composer/packages/client/src/pages/setting/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,13 @@ const SettingPage: React.FC<RouteComponentProps<{ '*': string }>> = () => {
}, [location.pathname]);

return (
<Page navLinks={links} title={title} toolbarItems={toolbarItems}>
<Page
mainRegionName={formatMessage('Settings editor')}
navLinks={links}
navRegionName={formatMessage('Settings menu')}
title={title}
toolbarItems={toolbarItems}
>
<Routes />
</Page>
);
Expand Down
2 changes: 1 addition & 1 deletion Composer/packages/client/src/pages/skills/skill-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ const SkillList: React.FC<ISkillListProps> = (props) => {

return (
<React.Fragment>
<div css={TableView}>
<div aria-label={formatMessage('List view')} css={TableView} role="region">
<ScrollablePane scrollbarVisibility={ScrollbarVisibility.auto}>
<DetailsList
isHeaderVisible
Expand Down