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

Fix accessibility issues due to aria-hidden and aria-labelledby in FileContent and CarouselFilmStrip #3836

Merged
merged 6 commits into from
Apr 11, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

- Resolves [#3087](https://github.com/microsoft/BotFramework-WebChat/issues/3087). External links in Markdown will now be appended with an "open in new window" icon and accessibility label, by [@compulim](https://github.com/compulim) in PR [#3817](https://github.com/microsoft/BotFramework-WebChat/pull/3817)
- Resolves [#2100](https://github.com/microsoft/BotFramework-WebChat/issues/2100). Add types declarations for Style Options in api bundle, by [@corinagum](https://github.com/corinagum), in PR [#3818](https://github.com/microsoft/BotFramework-WebChat/pull/3818)
- Fixes [#3810](https://github.com/microsoft/BotFramework-WebChat/issues/3810). Removes `aria-hidden` from elements that have a focusable child, by [@corinagum](https://github.com/corinagum) in PR [#3836](https://github.com/microsoft/BotFramework-WebChat/pull/3836)
- Fixes [#3811](https://github.com/microsoft/BotFramework-WebChat/issues/3811). Removes erroneous `aria-labelledby` from carousel, by [@corinagum](https://github.com/corinagum) in PR [#3836](https://github.com/microsoft/BotFramework-WebChat/pull/3836)

### Changed

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
expect,
host,
pageObjects,
shareObservable,
corinagum marked this conversation as resolved.
Show resolved Hide resolved
timeouts,
token
} = window.WebChatTest;
Expand Down
56 changes: 56 additions & 0 deletions __tests__/html/accessibility.attachment.aria.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<!DOCTYPE html>
<html lang="en-US">
<head>
<script crossorigin="anonymous" src="/__dist__/testharness.js"></script>
<script crossorigin="anonymous" src="/__dist__/webchat-es5.js"></script>
</head>
<body>
<div id="webchat"></div>
<script type="text/babel" data-presets="env,stage-3,react">
const { conditions, createStore, expect, host, pageObjects, timeouts, token } = window.WebChatTest;

const {
Components: { AdaptiveCardContent }
} = window.WebChat;

(async function () {
const store = createStore();
const directLine = window.WebChat.createDirectLine({ token: await token.fetchDirectLineToken() });
const baseProps = { directLine, store };
const webChatElement = document.getElementById('webchat');

window.WebChat.renderWebChat(baseProps, webChatElement);

await pageObjects.wait(conditions.uiConnected(), timeouts.directLine);

await pageObjects.sendMessageViaSendBox('document-word', { waitForSend: true });
await pageObjects.wait(conditions.minNumActivitiesShown(2), timeouts.directLine);
await pageObjects.wait(conditions.scrollToBottomCompleted(), timeouts.directLine);

const fileContentAriaHidden = document.querySelector('.webchat__fileContent').getAttribute('aria-hidden');

expect(fileContentAriaHidden).toBeFalsy();

const fileContentButtonLinkLabel = document
.querySelector('.webchat__fileContent__buttonLink')
.getAttribute('aria-label');

expect(fileContentButtonLinkLabel).toBeTruthy();

await pageObjects.sendMessageViaSendBox('carousel', { waitForSend: true });
await pageObjects.wait(conditions.minNumActivitiesShown(4), timeouts.directLine);
await pageObjects.wait(conditions.scrollToBottomCompleted(), timeouts.directLine);

const carouselContainer = document.querySelector('.webchat__carousel-filmstrip').getAttribute('aria-labelledby');

expect(carouselContainer).toBeFalsy();

await host.done();
})().catch(async err => {
console.error(err);

await host.error(err);
});
</script>
</body>
</html>
8 changes: 8 additions & 0 deletions __tests__/html/accessibility.attachment.aria.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* @jest-environment ./__tests__/html/__jest__/WebChatEnvironment.js
*/

describe('accessibility requirement', () => {
test('Element with aria-label should not have parent aria-hidden', () =>
runHTMLTest('accessibility.attachment.aria'));
});
12 changes: 1 addition & 11 deletions packages/component/src/Activity/CarouselFilmStrip.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import ScreenReaderText from '../ScreenReaderText';
import textFormatToContentType from '../Utils/textFormatToContentType';
import useStyleSet from '../hooks/useStyleSet';
import useStyleToEmotionObject from '../hooks/internal/useStyleToEmotionObject';
import useUniqueId from '../hooks/internal/useUniqueId';

const { useAvatarForBot, useAvatarForUser, useDirection, useLocalizer, useStyleOptions } = hooks;

Expand Down Expand Up @@ -127,7 +126,6 @@ const CarouselFilmStrip = ({
const [{ initials: botInitials }] = useAvatarForBot();
const [{ initials: userInitials }] = useAvatarForUser();
const [direction] = useDirection();
const ariaLabelId = useUniqueId('webchat__carousel-filmstrip__id');
const localize = useLocalizer();
const rootClassName = useStyleToEmotionObject()(ROOT_STYLE) + '';
const showActivityStatus = typeof renderActivityStatus === 'function';
Expand Down Expand Up @@ -171,7 +169,6 @@ const CarouselFilmStrip = ({

return (
<div
aria-labelledby={ariaLabelId}
corinagum marked this conversation as resolved.
Show resolved Hide resolved
className={classNames(
'webchat__carousel-filmstrip',
{
Expand All @@ -196,14 +193,7 @@ const CarouselFilmStrip = ({
<div className="webchat__carousel-filmstrip__avatar-gutter">{showAvatar && renderAvatar({ activity })}</div>
<div className="webchat__carousel-filmstrip__content">
{!!activityDisplayText && (
<div
aria-roledescription="message"
className="webchat__carousel-filmstrip__message"
// Disable "Prop `id` is forbidden on DOM Nodes" rule because we are using the ID prop for accessibility.
/* eslint-disable-next-line react/forbid-dom-props */
id={ariaLabelId}
role="group"
>
<div aria-roledescription="message" className="webchat__carousel-filmstrip__message" role="group">
<ScreenReaderText text={greetingAlt} />
<Bubble
className="webchat__carousel-filmstrip__bubble"
Expand Down
6 changes: 1 addition & 5 deletions packages/component/src/Attachment/FileContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import PropTypes from 'prop-types';
import React from 'react';

import DownloadIcon from './Assets/DownloadIcon';
import ScreenReaderText from '../ScreenReaderText';
import useStyleSet from '../hooks/useStyleSet';
import useStyleToEmotionObject from '../hooks/internal/useStyleToEmotionObject';

Expand Down Expand Up @@ -83,20 +82,17 @@ const FileContent = ({ className, href, fileName, size }) => {

return (
<div
aria-hidden={true}
className={classNames('webchat__fileContent', rootClassName, fileContentStyleSet + '', (className || '') + '')}
>
<ScreenReaderText text={alt} />
{href ? (
<a
aria-hidden={true}
aria-label={alt}
className="webchat__fileContent__buttonLink"
download={fileName}
href={href}
rel="noopener noreferrer"
target="_blank"
>
{/* Although nested, Chrome v75 does not respect the above aria-hidden and makes the below aria-hidden in FileContentBadge necessary */}
<FileContentBadge downloadIcon={true} fileName={fileName} size={size} />
</a>
) : (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@
VideoCardContent
},
createStore,
createStyleSet,
corinagum marked this conversation as resolved.
Show resolved Hide resolved
ReactWebChat
} = window.WebChat;
const { useCallback, useMemo, useState } = window.React;
Expand Down