Skip to content

Commit f1f5c81

Browse files
authored
fix(usm): add aria label (#3191)
fix(usm): add aria label expires Requested changes: add aria-label="expires" and to the span containing the clock icon.
1 parent b35e977 commit f1f5c81

5 files changed

Lines changed: 31 additions & 4 deletions

File tree

‎i18n/en-US.properties‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1656,6 +1656,8 @@ boxui.unifiedShare.emailModalTitle = Send Link to ‘{itemName}’
16561656
boxui.unifiedShare.enterAtLeastOneEmail = Enter at least one valid email
16571657
# Tooltip text shown in the share modal, encouraging users to enter email addresses to share the item with
16581658
boxui.unifiedShare.enterEmailAddressesCalloutText = Share this item with coworkers by entering their email addresses
1659+
# Label for tooltips or other components that display expiration icons
1660+
boxui.unifiedShare.expiresMessage = Expires
16591661
# This is label for the button so a user understands the new interface
16601662
boxui.unifiedShare.ftuxConfirmLabel = Got it
16611663
# Text for the body of the tooltip for the ftux experience when the edit option is available for the user

‎src/features/unified-share-modal/SharedLinkSection.js‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,6 @@ class SharedLinkSection extends React.Component<Props, State> {
459459
const isToggleEnabled = (canAddSharedLink || canRemoveSharedLink) && !submitting;
460460

461461
let linkText;
462-
463462
if (isSharedLinkEnabled) {
464463
linkText = <FormattedMessage {...messages.linkShareOn} />;
465464
if (expirationTimestamp && expirationTimestamp !== 0) {
@@ -472,7 +471,11 @@ class SharedLinkSection extends React.Component<Props, State> {
472471
expiration: convertToMs(expirationTimestamp),
473472
})}
474473
>
475-
<span className="shared-link-expiration-badge" role="img">
474+
<span
475+
aria-label={intl.formatMessage(messages.expiresMessage)}
476+
className="shared-link-expiration-badge"
477+
role="img"
478+
>
476479
<IconClock color={bdlWatermelonRed} />
477480
</span>
478481
</Tooltip>

‎src/features/unified-share-modal/__tests__/SharedLinkSection.test.js‎

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ describe('features/unified-share-modal/SharedLinkSection', () => {
148148
expect(wrapper).toMatchSnapshot();
149149
});
150150

151-
test('should account for shared link expirations being set', () => {
151+
test('should match snapshot when shared link expiration is set', () => {
152152
const wrapper = getWrapper({
153153
sharedLink: {
154154
accessLevel: 'peopleInYourCompany',
@@ -310,6 +310,22 @@ describe('features/unified-share-modal/SharedLinkSection', () => {
310310
expect(wrapper.exists('.email-shared-link-btn')).toBe(emailButtonExists);
311311
});
312312

313+
test('should have aria-label and role on shared link expiration badge when expiration timestamp exists', () => {
314+
// Set an expiration timestamp so that Toggle is rendered with expiration icon
315+
const sharedLink = {
316+
expirationTimestamp: 1,
317+
url: 'https://example.com/shared-link',
318+
};
319+
const wrapper = getWrapper({ sharedLink });
320+
const toggle = wrapper.find('Toggle');
321+
322+
// The aria-label attr is on a span, which is contained within the label of the Toggle component
323+
const spanLabel = toggle.dive().find('.shared-link-expiration-badge');
324+
325+
expect(spanLabel.prop('aria-label')).toBe('Expires');
326+
expect(spanLabel.prop('role')).toBe('img');
327+
});
328+
313329
describe('componentDidMount()', () => {
314330
test('should attempt shared link creation when component is mounted with initial, empty shared link data', () => {
315331
const sharedLink = { url: '', isNewSharedLink: false };

‎src/features/unified-share-modal/__tests__/__snapshots__/SharedLinkSection.test.js.snap‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`features/unified-share-modal/SharedLinkSection should account for shared link expirations being set 1`] = `
3+
exports[`features/unified-share-modal/SharedLinkSection should match snapshot when shared link expiration is set 1`] = `
44
<div
55
className="be"
66
>
@@ -41,6 +41,7 @@ exports[`features/unified-share-modal/SharedLinkSection should account for share
4141
theme="default"
4242
>
4343
<span
44+
aria-label="Expires"
4445
className="shared-link-expiration-badge"
4546
role="img"
4647
>

‎src/features/unified-share-modal/messages.js‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,11 @@ const messages = defineMessages({
540540
'Text to show when the number of contact email addresses displayed on a tooltip exceeds the maximum amount that can be displayed',
541541
id: 'boxui.unifiedShare.contactEmailsTooltipText',
542542
},
543+
expiresMessage: {
544+
defaultMessage: 'Expires',
545+
description: 'Label for tooltips or other components that display expiration icons',
546+
id: 'boxui.unifiedShare.expiresMessage',
547+
},
543548
});
544549

545550
export default messages;

0 commit comments

Comments
 (0)