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: reapply tooltip additions #3362

Merged
merged 22 commits into from
Jun 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
8f3550b
reapply tooltip additions
beyackle Jun 9, 2020
dece4ce
Merge branch 'master' into beyackle/2006TooltipRedo
beyackle Jun 9, 2020
0c473f3
Merge branch 'master' into beyackle/2006TooltipRedo
beyackle Jun 9, 2020
6ac6fec
maybe fix e2e tests
beyackle Jun 9, 2020
fb10ce9
Merge branch 'master' into beyackle/2006TooltipRedo
beyackle Jun 10, 2020
1d0cc8d
Merge branch 'master' into beyackle/2006TooltipRedo
beyackle Jun 10, 2020
4c558f5
merge and resolve conflicts
beyackle Jun 15, 2020
86155cd
Merge branch 'master' into beyackle/2006TooltipRedo
beyackle Jun 15, 2020
5ecafb6
Update OpenObjectField.tsx
beyackle Jun 15, 2020
dbb211a
Merge branch 'master' into beyackle/2006TooltipRedo
beyackle Jun 16, 2020
72e593a
remove force:true
beyackle Jun 17, 2020
75dd5a2
Merge branch 'master' into beyackle/2006TooltipRedo
beyackle Jun 17, 2020
ad923f6
fix logic on nav tooltips
beyackle Jun 17, 2020
7e3dc53
Merge branch 'master' into beyackle/2006TooltipRedo
beyackle Jun 17, 2020
102da55
Update LUPage.spec.ts
beyackle Jun 17, 2020
de8ba76
re-remove plugins directory (moved in another commit)
beyackle Jun 17, 2020
2f66990
add parentsUntil to tests
beyackle Jun 17, 2020
cc55fa3
fix tests
beyackle Jun 17, 2020
d4cc8dc
Merge branch 'master' into beyackle/2006TooltipRedo
beyackle Jun 17, 2020
fdf9c10
fix tests
beyackle Jun 17, 2020
5520353
Merge branch 'beyackle/2006TooltipRedo' of https://github.com/microso…
beyackle Jun 17, 2020
59421f5
defocus tooltips during tests
beyackle Jun 18, 2020
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
7 changes: 5 additions & 2 deletions Composer/cypress/integration/LUPage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,15 @@ context('LU Page', () => {

cy.get('.toggleEditMode button').should('not.exist');

// by default is table view
// by default it goes to table view
cy.findByTestId('LUPage').findByTestId('table-view').should('exist');

// move away from the User Input button (clicking the logo should do nothing)
cy.findByAltText('Composer Logo').click();

// nav to ToDoBotWithLuisSample.main dialog
cy.findByTestId('ProjectTree').within(() => {
cy.findByText('__TestToDoBotWithLuisSample').click();
cy.findByText('__TestToDoBotWithLuisSample').click('left');
});
cy.get('.toggleEditMode button').as('switchButton');
// goto edit-mode
Expand Down
3 changes: 3 additions & 0 deletions Composer/cypress/integration/NotificationPage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ context('Notification Page', () => {

cy.findByTestId('LeftNav-CommandBarButtonNotifications').click();

// move away from the Notifications button (clicking the logo should do nothing)
cy.findByAltText('Composer Logo').click();

cy.findByTestId('notifications-table-view').within(() => {
cy.findAllByText('__testtodobotwithluissample.dialog').should('exist').first().dblclick();
});
Expand Down
2 changes: 1 addition & 1 deletion Composer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,4 @@
"dependencies": {
"cross-env": "^6.0.3"
}
}
}
32 changes: 20 additions & 12 deletions Composer/packages/client/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import React, { forwardRef, useContext, useEffect, useState, Fragment, Suspense
import { initializeIcons } from 'office-ui-fabric-react/lib/Icons';
import { IconButton } from 'office-ui-fabric-react/lib/Button';
import { FocusZone } from 'office-ui-fabric-react/lib/FocusZone';
import { TooltipHost, DirectionalHint } from 'office-ui-fabric-react/lib/Tooltip';
import formatMessage from 'format-message';

import { Header } from './components/Header';
Expand Down Expand Up @@ -44,10 +45,13 @@ export const App: React.FC = () => {
onboardingSetComplete(onboardingState.getComplete());
}, []);

const mapNavItemTo = (x) => resolveToBasePath(BASEPATH, x);
const mapNavItemTo = (relPath: string) => resolveToBasePath(BASEPATH, relPath);

const renderAppUpdater = isElectron();

const globalNavButtonText = sideBarExpand ? formatMessage('Collapse Navigation') : formatMessage('Expand Navigation');
const showTooltips = (link) => !sideBarExpand && !link.disabled;

return (
<Fragment>
<div
Expand All @@ -67,17 +71,19 @@ export const App: React.FC = () => {
<div css={main}>
<nav css={sideBar(sideBarExpand)}>
<div>
<IconButton
ariaLabel={sideBarExpand ? formatMessage('Collapse Nav') : formatMessage('Expand Nav')}
css={globalNav}
data-testid={'LeftNavButton'}
iconProps={{
iconName: 'GlobalNavButton',
}}
onClick={() => {
setSideBarExpand(!sideBarExpand);
}}
/>
<TooltipHost content={globalNavButtonText} directionalHint={DirectionalHint.rightCenter}>
<IconButton
ariaLabel={globalNavButtonText}
css={globalNav}
data-testid={'LeftNavButton'}
iconProps={{
iconName: 'GlobalNavButton',
}}
onClick={() => {
setSideBarExpand((current) => !current);
}}
/>
</TooltipHost>
<div css={dividerTop} />{' '}
<FocusZone allowFocusRoot>
{topLinks.map((link, index) => {
Expand All @@ -88,6 +94,7 @@ export const App: React.FC = () => {
exact={link.exact}
iconName={link.iconName}
labelName={link.labelName}
showTooltip={showTooltips(link)}
to={mapNavItemTo(link.to)}
/>
);
Expand All @@ -104,6 +111,7 @@ export const App: React.FC = () => {
exact={link.exact}
iconName={link.iconName}
labelName={link.labelName}
showTooltip={showTooltips(link)}
to={mapNavItemTo(link.to)}
/>
);
Expand Down
14 changes: 12 additions & 2 deletions Composer/packages/client/src/components/NavItem/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { jsx, css } from '@emotion/core';
import { useCallback, useContext } from 'react';
import { Link } from '@reach/router';
import { Icon } from 'office-ui-fabric-react/lib/Icon';
import { TooltipHost, DirectionalHint } from 'office-ui-fabric-react/lib/Tooltip';

import { StoreContext } from '../../store';
import { useLocation, useRouterCache } from '../../utils/hooks';
Expand All @@ -25,14 +26,15 @@ export interface INavItemProps {
iconName: string;
labelName: string;
disabled: boolean;
showTooltip: boolean;
}

export const NavItem: React.FC<INavItemProps> = (props) => {
const {
actions: { onboardingAddCoachMarkRef },
} = useContext(StoreContext);

const { to, iconName, labelName, disabled } = props;
const { to, iconName, labelName, disabled, showTooltip } = props;
const {
location: { pathname },
} = useLocation();
Expand All @@ -43,6 +45,8 @@ export const NavItem: React.FC<INavItemProps> = (props) => {

const addRef = useCallback((ref) => onboardingAddCoachMarkRef({ [`nav${labelName.replace(' ', '')}`]: ref }), []);

const iconElement = <Icon iconName={iconName} styles={icon(active, disabled)} />;

const activeArea = (
<div
aria-disabled={disabled}
Expand All @@ -51,7 +55,13 @@ export const NavItem: React.FC<INavItemProps> = (props) => {
data-testid={active ? 'ActiveLeftNavItem' : undefined}
tabIndex={-1}
>
<Icon iconName={iconName} styles={icon(active, disabled)} />
{showTooltip ? (
<TooltipHost content={labelName} directionalHint={DirectionalHint.rightCenter}>
{iconElement}
</TooltipHost>
) : (
iconElement
)}
{labelName}
</div>
);
Expand Down
34 changes: 20 additions & 14 deletions Composer/packages/client/src/components/ProjectTree/treeItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
import { jsx } from '@emotion/core';
import React from 'react';
import { OverflowSet, IOverflowSetItemProps } from 'office-ui-fabric-react/lib/OverflowSet';
import { TooltipHost, DirectionalHint } from 'office-ui-fabric-react/lib/Tooltip';
import { IconButton } from 'office-ui-fabric-react/lib/Button';
import { Icon } from 'office-ui-fabric-react/lib/Icon';
import formatMessage from 'format-message';

import { moreButton, overflowSet, menuStyle, navItem, itemText, content } from './styles';

Expand Down Expand Up @@ -49,23 +51,27 @@ const onRenderItem = (item: IOverflowSetItemProps) => {
};

const onRenderOverflowButton = (isRoot: boolean, isActive: boolean) => {
const moreLabel = formatMessage('Actions');
const showIcon = !isRoot;
return (overflowItems) => {
return showIcon ? (
<IconButton
className="dialog-more-btn"
data-is-focusable={isActive}
data-testid="dialogMoreButton"
menuIconProps={{ iconName: 'MoreVertical' }}
menuProps={{ items: overflowItems, styles: menuStyle }}
role="cell"
styles={moreButton(isActive)}
onKeyDown={(e) => {
if (e.key === 'Enter') {
e.stopPropagation();
}
}}
/>
<TooltipHost content={moreLabel} directionalHint={DirectionalHint.rightCenter}>
<IconButton
ariaLabel={moreLabel}
className="dialog-more-btn"
data-is-focusable={isActive}
data-testid="dialogMoreButton"
menuIconProps={{ iconName: 'MoreVertical' }}
menuProps={{ items: overflowItems, styles: menuStyle }}
role="cell"
styles={moreButton(isActive)}
onKeyDown={(e) => {
if (e.key === 'Enter') {
e.stopPropagation();
}
}}
/>
</TooltipHost>
) : null;
};
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ const TableView: React.FC<TableViewProps> = (props) => {
setTemplates(file.templates);
}, [file, activeDialog, projectId]);

const moreLabel = formatMessage('Actions');

const onClickEdit = useCallback(
(template: LgTemplate) => {
const { name } = template;
Expand Down Expand Up @@ -183,15 +185,17 @@ const TableView: React.FC<TableViewProps> = (props) => {
data: 'string',
onRender: (item, index) => {
return (
<IconButton
ariaLabel={formatMessage('actions')}
menuIconProps={{ iconName: 'MoreVertical' }}
menuProps={{
shouldFocusOnMount: true,
items: getTemplatesMoreButtons(item, index),
}}
styles={{ menuIcon: { color: NeutralColors.black, fontSize: FontSizes.size16 } }}
/>
<TooltipHost calloutProps={{ gapSpace: 10 }} content={moreLabel}>
<IconButton
ariaLabel={moreLabel}
menuIconProps={{ iconName: 'MoreVertical' }}
menuProps={{
shouldFocusOnMount: true,
items: getTemplatesMoreButtons(item, index),
}}
styles={{ menuIcon: { color: NeutralColors.black, fontSize: FontSizes.size16 } }}
/>
</TooltipHost>
);
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ const TableView: React.FC<TableViewProps> = (props) => {
const [intents, setIntents] = useState<Intent[]>([]);
const listRef = useRef(null);

const moreLabel = formatMessage('Open inline editor');

function getIntentState(file: LuFile): string {
if (!file.diagnostics) {
return formatMessage('Error');
Expand Down Expand Up @@ -196,15 +198,17 @@ const TableView: React.FC<TableViewProps> = (props) => {
data: 'string',
onRender: (item, index) => {
return (
<IconButton
ariaLabel={formatMessage('Open inline editor')}
menuIconProps={{ iconName: 'MoreVertical' }}
menuProps={{
shouldFocusOnMount: true,
items: getTemplatesMoreButtons(item, index),
}}
styles={{ menuIcon: { color: NeutralColors.black, fontSize: FontSizes.size16 } }}
/>
<TooltipHost calloutProps={{ gapSpace: 10 }} content={moreLabel}>
<IconButton
ariaLabel={moreLabel}
menuIconProps={{ iconName: 'MoreVertical' }}
menuProps={{
shouldFocusOnMount: true,
items: getTemplatesMoreButtons(item, index),
}}
styles={{ menuIcon: { color: NeutralColors.black, fontSize: FontSizes.size16 } }}
/>
</TooltipHost>
);
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { jsx } from '@emotion/core';
import { useContext, useState } from 'react';
import formatMessage from 'format-message';
import { DefinitionSummary } from '@bfc/shared';
import { TooltipHost, DirectionalHint } from 'office-ui-fabric-react/lib/Tooltip';

// TODO: leak of visual-sdk domain (EdgeAddButtonSize)
import { EdgeAddButtonSize } from '../../../adaptive-flow-renderer/constants/ElementSizes';
Expand Down Expand Up @@ -38,8 +39,12 @@ export const EdgeMenu: React.FC<EdgeMenuProps> = ({ id, onClick }) => {
};

const [menuSelected, setMenuSelected] = useState<boolean>(false);
let boxShaow = '0px 2px 8px rgba(0, 0, 0, 0.1)';
boxShaow += menuSelected ? `,0 0 0 2px ${ObiColors.AzureBlue}` : nodeSelected ? `, 0 0 0 2px ${ObiColors.Black}` : '';
let boxShadow = '0px 2px 8px rgba(0, 0, 0, 0.1)';
boxShadow += menuSelected
? `,0 0 0 2px ${ObiColors.AzureBlue}`
: nodeSelected
? `, 0 0 0 2px ${ObiColors.Black}`
: '';

const handleMenuShow = (menuSelected) => {
setMenuSelected(menuSelected);
Expand All @@ -57,40 +62,45 @@ export const EdgeMenu: React.FC<EdgeMenuProps> = ({ id, onClick }) => {
// Custom Action 'oneOf' arrays from schema file
customSchemas.map((x) => x.oneOf).filter((oneOf) => Array.isArray(oneOf) && oneOf.length) as DefinitionSummary[][]
);

const moreLabel = formatMessage('Add');

return (
<div
style={{
width: EdgeAddButtonSize.width,
height: EdgeAddButtonSize.height,
borderRadius: '8px',
backdropFilter: 'white',
boxShadow: boxShaow,
boxShadow: boxShadow,
overflow: 'hidden',
background: 'white',
}}
{...declareElementAttributes(id)}
>
<IconMenu
handleMenuShow={handleMenuShow}
iconName="Add"
iconSize={7}
iconStyles={{
color: '#005CE6',
selectors: {
':focus': {
outline: 'none',
selectors: {
'::after': {
outline: 'none !important',
<TooltipHost content={moreLabel} directionalHint={DirectionalHint.rightCenter}>
<IconMenu
handleMenuShow={handleMenuShow}
iconName="Add"
iconSize={7}
iconStyles={{
color: '#005CE6',
selectors: {
':focus': {
outline: 'none',
selectors: {
'::after': {
outline: 'none !important',
},
},
},
},
},
}}
label={formatMessage('Add')}
menuItems={menuItems}
nodeSelected={nodeSelected}
/>
}}
label={moreLabel}
menuItems={menuItems}
nodeSelected={nodeSelected}
/>
</TooltipHost>
</div>
);
};
Loading