Skip to content

Commit

Permalink
a11y: change button to icon in FieldLabel.tsx (microsoft#2551)
Browse files Browse the repository at this point in the history
* Update FieldLabel.tsx

* Update FieldLabel.tsx

Co-authored-by: Chris Whitten <christopher.whitten@microsoft.com>
Co-authored-by: Andy Brown <asbrown002@gmail.com>
  • Loading branch information
3 people authored Apr 8, 2020
1 parent 56ac846 commit 6f9adb1
Showing 1 changed file with 29 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the MIT License.
import React from 'react';
import { DirectionalHint, TooltipHost, TooltipDelay } 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 { Label } from 'office-ui-fabric-react/lib/Label';
import { Link } from 'office-ui-fabric-react/lib/Link';
import { NeutralColors } from '@uifabric/fluent-theme';
Expand Down Expand Up @@ -32,7 +32,9 @@ const DescriptionCallout: React.FC<DescriptionCalloutProps> = function Descripti
styles: { root: { width: '288px', padding: '17px 28px' } },
onRenderContent: () => (
<div>
<h3 style={{ fontSize: '20px', margin: '0', marginBottom: '10px' }}>{title}</h3>
<h3 style={{ fontSize: '20px', margin: '0', marginBottom: '10px' }} aria-label={title + '.'}>
{title}
</h3>
<p>{description}</p>
{helpLink && (
<Link href={helpLink} target="_blank" rel="noopener noreferrer">
Expand All @@ -43,22 +45,24 @@ const DescriptionCallout: React.FC<DescriptionCalloutProps> = function Descripti
),
}}
>
<IconButton
aria-labelledby={`${id}-description`}
iconProps={{
iconName: 'Unknown',
}}
styles={{
root: { width: '20px', minWidth: '20px', height: '20px' },
rootHovered: { backgroundColor: 'transparent' },
rootChecked: { backgroundColor: 'transparent' },
icon: {
color: NeutralColors.gray160,
fontSize: '12px',
marginBottom: '-2px',
},
}}
/>
<div tabIndex={0}>
<Icon
aria-labelledby={`${id}-description`}
iconName={'Unknown'}
styles={{
root: {
width: '16px',
minWidth: '16px',
height: '16px',
color: NeutralColors.gray160,
fontSize: '12px',
marginBottom: '-2px',
paddingLeft: '4px',
paddingTop: '4px',
},
}}
/>
</div>
</TooltipHost>
);
};
Expand Down Expand Up @@ -90,7 +94,13 @@ const FieldLabel: React.FC<FieldLabelProps> = props => {
},
}}
>
{label}
<div
style={{
marginRight: '4px',
}}
>
{label}
</div>
<DescriptionCallout description={description} id={id} title={label} helpLink={helpLink} />
</Label>
);
Expand Down

0 comments on commit 6f9adb1

Please sign in to comment.