Skip to content

Commit

Permalink
fix: add single-click-to-open links (microsoft#2847)
Browse files Browse the repository at this point in the history
Co-authored-by: Chris Whitten <christopher.whitten@microsoft.com>
  • Loading branch information
beyackle and cwhitten authored Apr 30, 2020
1 parent 9a540ac commit a414fca
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import path from 'path';
import { jsx } from '@emotion/core';
import { useMemo, useState } from 'react';
import { Icon } from 'office-ui-fabric-react/lib/Icon';
import { Link } from 'office-ui-fabric-react/lib/Link';
import { TooltipHost } from 'office-ui-fabric-react/lib/Tooltip';
import { Sticky, StickyPositionType } from 'office-ui-fabric-react/lib/Sticky';
import { ScrollablePane, ScrollbarVisibility } from 'office-ui-fabric-react/lib/ScrollablePane';
Expand Down Expand Up @@ -58,13 +59,23 @@ const _renderIcon = (file: File) => {
return <img src={url} className={detailListClass.fileIconImg} alt={`${iconName} file icon`} />;
};

const _renderNameColumn = (file: File) => {
const _renderNameColumn = (onFileChosen: (file: File) => void) => (file: File) => {
const iconName = getFileIconName(file);
return (
<div data-is-focusable={true} css={tableCell}>
<div tabIndex={-1} css={content} aria-label={`${iconName} Name is ${file.name}`}>
<Link
aria-label={
file.name === '..'
? formatMessage('previous folder')
: formatMessage('{icon} name is {file}', {
icon: iconName,
file: file.name,
})
}
onClick={() => onFileChosen(file)}
>
{file.name}
</div>
</Link>
</div>
);
};
Expand Down Expand Up @@ -99,7 +110,7 @@ export const FileSelector: React.FC<FileSelectorProps> = props => {
sortAscendingAriaLabel: formatMessage('Sorted A to Z'),
sortDescendingAriaLabel: formatMessage('Sorted Z to A'),
data: 'string',
onRender: _renderNameColumn,
onRender: _renderNameColumn(onFileChosen),
isPadded: true,
},
{
Expand Down
8 changes: 4 additions & 4 deletions Composer/packages/client/src/pages/home/RecentBotList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
/** @jsx jsx */
import { jsx } from '@emotion/core';
import { TooltipHost } from 'office-ui-fabric-react/lib/Tooltip';
import { Link } from 'office-ui-fabric-react/lib/Link';
import { Sticky, StickyPositionType } from 'office-ui-fabric-react/lib/Sticky';
import { ScrollablePane, ScrollbarVisibility } from 'office-ui-fabric-react/lib/ScrollablePane';
import { IObjectWithKey } from 'office-ui-fabric-react/lib/MarqueeSelection';
Expand Down Expand Up @@ -44,13 +45,12 @@ export function RecentBotList(props: RecentBotListProps): JSX.Element {
onRender: item => {
return (
<div css={tableCell} data-is-focusable={true}>
<div
tabIndex={-1}
css={content}
<Link
aria-label={formatMessage(`Bot name is {botName}`, { botName: item.name })}
onClick={() => onItemChosen(item)}
>
{item.name}
</div>
</Link>
</div>
);
},
Expand Down

0 comments on commit a414fca

Please sign in to comment.