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

Bump deps and remove remark and strip-markdown #3917

Merged
merged 37 commits into from
Jun 3, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
253627f
Bump deps
compulim May 27, 2021
8098c36
Go back to v1
compulim May 27, 2021
c81250a
Remove remark and strip-markdown
compulim May 27, 2021
2b7332d
Revert to v1
compulim May 27, 2021
02d1878
Revert to v1
compulim May 27, 2021
b76f630
Revert to v1
compulim May 27, 2021
3de4f40
Supports summary field
compulim May 27, 2021
e6e8656
Ignore summary field
compulim May 27, 2021
3848258
Strip Markdown from HTML
compulim May 28, 2021
6844630
Add speak field not present
compulim May 28, 2021
e24b0eb
Update strip Markdown
compulim May 28, 2021
7070d0b
Narrate empty text field
compulim May 28, 2021
8326dd0
Use different text computation for HTML/Markdown
compulim May 28, 2021
2bdea47
Clean up
compulim May 28, 2021
b5c8e2e
Update with samples
compulim May 28, 2021
ea061d1
More inline elements
compulim May 28, 2021
01ecd81
Clean up
compulim May 28, 2021
6bf131d
MessageBack must not be Markdown
compulim May 28, 2021
e136c8f
Lockdown performance
compulim May 28, 2021
884c0bc
Add snapshots
compulim May 28, 2021
e4c9ef1
Fix MessageBack
compulim May 28, 2021
8f9ba7f
Remove renderMarkdownAsHTML
compulim May 28, 2021
6b6a974
Fix ESLint
compulim May 28, 2021
36afb79
Assume plain text if renderMarkdown is null
compulim May 28, 2021
1000321
Compute text alternatives using alt field
compulim Jun 1, 2021
ab7242b
Change to webchat:fallback-text field
compulim Jun 2, 2021
cf2c82f
Bump to [email protected]
compulim Jun 2, 2021
70375f5
Typo
compulim Jun 2, 2021
4bc5c60
Update entry
compulim Jun 2, 2021
246eb64
Typo
compulim Jun 2, 2021
510348f
Update entry
compulim Jun 2, 2021
80d6a27
Link to issue
compulim Jun 2, 2021
86fc365
Undo package*.json for core/embed
compulim Jun 2, 2021
c85d9dd
Move allTextContents into testHelpers
compulim Jun 3, 2021
9d862ef
Add @param
compulim Jun 3, 2021
8ee4888
Apply PR suggestions
compulim Jun 3, 2021
f9060f2
Update text
compulim Jun 3, 2021
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
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@
...baseActivity,
speak: '',
text: 'Empty string for "speak" property.'
},
{
// No "text" property.
...baseActivity
}
]),
store: testHelpers.createStore(),
Expand All @@ -75,15 +79,15 @@
);

await pageConditions.uiConnected();
await pageConditions.numActivitiesShown(3);
await pageConditions.numActivitiesShown(4);

const screenReaderTexts = [].map.call(
document.querySelector('[aria-roledescription="transcript"][role="log"]').children,
child => allTextContents(child).join('\n')
);

// The last activity have "speak" property set to empty string. It is treated as role="presentation" and not emitted DOM element for screen reader.
expect(screenReaderTexts).toHaveLength(2);
expect(screenReaderTexts).toHaveLength(3);

// In screen reader transcript, the attachment are rendered and narrated.
expect(screenReaderTexts[0]).toBe(
Expand All @@ -92,6 +96,7 @@

// No attachments should be narrated.
expect(screenReaderTexts[1]).toBe('Bot said:\nWith "speak" property.\nSent at January 1 at 12:34 PM');
expect(screenReaderTexts[2]).toBe('Bot said:\nA text: Hello.\nA text: World!\nSent at January 1 at 12:34 PM');

const activityAlts = [].map.call(
document.querySelectorAll(
Expand All @@ -101,14 +106,15 @@
);

// The last activity have "speak" property set to empty string. It is treated as role="presentation" and not emitted DOM element for screen reader.
expect(screenReaderTexts).toHaveLength(2);
expect(screenReaderTexts).toHaveLength(3);

// In interactive transcript, this is narrated as "2 attachments".
expect(activityAlts[0]).toBe(
'Bot said:\nNo “speak” property.\n2 attachments.\nSent at January 1 at 12:34 PM'
);

expect(activityAlts[1]).toBe('Bot said:\nWith "speak" property.\nSent at January 1 at 12:34 PM');
expect(activityAlts[2]).toBe('Bot said:\n2 attachments.\nSent at January 1 at 12:34 PM');
});
</script>
</body>
Expand Down
4 changes: 2 additions & 2 deletions packages/component/src/BasicTranscript.js
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,7 @@ const InternalTranscript = ({ activityElementsRef, className }) => {
role="log"
>
{renderingElements
.filter(({ textAlt }) => textAlt)
.filter(({ textAlt }) => textAlt !== false)
.map(({ activity, liveRegionKey, textAlt }) => (
<Fade fadeAfter={internalLiveRegionFadeAfter} key={liveRegionKey}>
{() => <ScreenReaderActivity activity={activity} textAlt={textAlt} />}
Expand Down Expand Up @@ -825,7 +825,7 @@ const InternalTranscript = ({ activityElementsRef, className }) => {
onMouseDownCapture={handleMouseDownCapture}
ref={callbackRef}
>
{textAlt && (
{textAlt !== false && (
compulim marked this conversation as resolved.
Show resolved Hide resolved
<ScreenReaderActivity
activity={activity}
id={ariaLabelID}
Expand Down
10 changes: 9 additions & 1 deletion packages/component/src/Utils/activityAltText.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,11 @@ export default function activityAltText(
const { speak } = activity;

if (speak === '') {
// We will treat the activity as presentational and skip narrating it.
return false;
} else if (typeof speak === 'string') {
}

if (typeof speak === 'string') {
if (isSSML(speak)) {
compulim marked this conversation as resolved.
Show resolved Hide resolved
return allTextContents(new DOMParser().parseFromString(activity.speak, 'application/xml')).join('').trim();
}
Expand All @@ -43,6 +46,11 @@ export default function activityAltText(

const text: string = activity?.channelData?.messageBack?.displayText || activity.text;

if (!text) {
// We will continue to narrate the activity, as empty.
return '';
}

if (textFormatToContentType(activity.textFormat) === 'text/markdown') {
return allTextContents(new DOMParser().parseFromString(renderMarkdownAsHTML(text), 'text/html'))
.join('')
Expand Down