Skip to content

Commit 48830ac

Browse files
Captions RTL languages such as hebrew + arabic need to be right aligned (#2999)
* captions arabic rtl * Change files * Duplicate change files for beta release * captions arabic rtl * captions arabic rtl * Update packages/react-composites CallWithChatComposite browser test snapshots * Update packages/react-composites CallComposite browser test snapshots --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 429dddf commit 48830ac

13 files changed

Lines changed: 83 additions & 6 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "patch",
3+
"comment": "Fix bug where captions rtl languages are not right aligned ",
4+
"packageName": "@azure/communication-react",
5+
"email": "carolinecao@microsoft.com",
6+
"dependentChangeType": "patch"
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "patch",
3+
"comment": "Fix bug where captions rtl languages are not right aligned ",
4+
"packageName": "@azure/communication-react",
5+
"email": "carolinecao@microsoft.com",
6+
"dependentChangeType": "patch"
7+
}

packages/react-components/src/components/Caption.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ export const _Caption = (props: _CaptionProps): JSX.Element => {
5656
<Stack.Item className={displayNameContainerClassName}>
5757
<Text className={displayNameClassName}>{displayName}</Text>
5858
</Stack.Item>
59-
<Stack.Item>
60-
<Text className={captionClassName}>{captionText}</Text>
59+
<Stack.Item className={captionClassName} dir="auto">
60+
{captionText}
6161
</Stack.Item>
6262
</Stack>
6363
</Stack>

packages/react-components/src/components/styles/Captions.style.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ export const displayNameClassName = mergeStyles({
2727
export const captionClassName = mergeStyles({
2828
fontWeight: 400,
2929
fontSize: _pxToRem(16),
30-
lineHeight: _pxToRem(22)
30+
lineHeight: _pxToRem(22),
31+
width: '100%'
3132
});
3233

3334
/**
@@ -61,7 +62,7 @@ export const captionsBannerClassName = mergeStyles({
6162
* @private
6263
*/
6364
export const captionsContentContainerClassName = mergeStyles({
64-
minWidth: 0
65+
width: '100%'
6566
});
6667

6768
/**

packages/react-composites/tests/browser/call/hermetic/ClosedCaptions.test.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import { buildUrlWithMockAdapter, defaultMockCallAdapterState, test } from './fixture';
55
import { expect } from '@playwright/test';
66
import { dataUiId, isTestProfileMobile, pageClick, stableScreenshot, waitForSelector } from '../../common/utils';
7-
import { IDS, captionsFeatureState } from '../../common/constants';
7+
import { IDS, captionsFeatureState, captionsFeatureStateArabic } from '../../common/constants';
88

99
/* @conditional-compile-remove(close-captions) */
1010
test.describe('Closed Captions Banner tests', async () => {
@@ -19,6 +19,17 @@ test.describe('Closed Captions Banner tests', async () => {
1919
expect(await stableScreenshot(page)).toMatchSnapshot('show-captions.png');
2020
});
2121

22+
test('Show RTL languages from right to left', async ({ page, serverUrl }) => {
23+
const initialState = defaultMockCallAdapterState();
24+
if (initialState?.call) {
25+
initialState.isTeamsCall = true;
26+
initialState.call.captionsFeature = captionsFeatureStateArabic;
27+
}
28+
await page.goto(buildUrlWithMockAdapter(serverUrl, initialState, { newControlBarExperience: 'true' }));
29+
await waitForSelector(page, dataUiId(IDS.videoGallery));
30+
expect(await stableScreenshot(page)).toMatchSnapshot('show-captions-RTL.png');
31+
});
32+
2233
test('Captions menu shows correct when clicked on desktop', async ({ page, serverUrl }, testInfo) => {
2334
if (isTestProfileMobile(testInfo)) {
2435
test.skip();

packages/react-composites/tests/browser/callwithchat/hermetic/ClosedCaptions.test.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import { loadCallPage, test } from './fixture';
55
import { expect } from '@playwright/test';
66
import { dataUiId, isTestProfileMobile, pageClick, stableScreenshot, waitForSelector } from '../../common/utils';
7-
import { IDS, captionsFeatureState } from '../../common/constants';
7+
import { IDS, captionsFeatureState, captionsFeatureStateArabic } from '../../common/constants';
88
import { defaultMockCallAdapterState, defaultMockRemoteParticipant } from '../../call/hermetic/fixture';
99

1010
/* @conditional-compile-remove(close-captions) */
@@ -20,6 +20,17 @@ test.describe('Closed Captions Banner tests', async () => {
2020
expect(await stableScreenshot(page)).toMatchSnapshot('show-captions.png');
2121
});
2222

23+
test('Show RTL languages from right to left', async ({ page, serverUrl }) => {
24+
const initialState = defaultMockCallAdapterState([defaultMockRemoteParticipant('Paul Bridges')]);
25+
if (initialState?.call) {
26+
initialState.isTeamsCall = true;
27+
initialState.call.captionsFeature = captionsFeatureStateArabic;
28+
}
29+
await loadCallPage(page, serverUrl, initialState);
30+
await waitForSelector(page, dataUiId(IDS.videoGallery));
31+
expect(await stableScreenshot(page)).toMatchSnapshot('show-captions-RTL.png');
32+
});
33+
2334
test('Captions menu shows correct when clicked on desktop', async ({ page, serverUrl }, testInfo) => {
2435
if (isTestProfileMobile(testInfo)) {
2536
test.skip();

packages/react-composites/tests/browser/common/constants.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,3 +125,43 @@ export const captionsFeatureState = {
125125
currentSpokenLanguage: 'en-us',
126126
isCaptionsFeatureActive: true
127127
};
128+
129+
export const captionsFeatureStateArabic = {
130+
captions: [
131+
{
132+
resultType: 'Final' as const,
133+
timestamp: new Date(0),
134+
speaker: {
135+
displayName: 'Participant 1',
136+
identifier: { communicationUserId: 'communicationId1', kind: 'communicationUser' as const }
137+
},
138+
spokenLanguage: 'ar-ae' as const,
139+
captionText: '!سعيد بلقائك! مرحبًا'
140+
},
141+
{
142+
resultType: 'Final' as const,
143+
timestamp: new Date(10000),
144+
speaker: {
145+
displayName: 'Participant 2',
146+
identifier: { communicationUserId: 'communicationId2', kind: 'communicationUser' as const }
147+
},
148+
spokenLanguage: 'ar-ae' as const,
149+
captionText: 'انا جيد، كيف حالك؟'
150+
},
151+
{
152+
resultType: 'Final' as const,
153+
timestamp: new Date(10001),
154+
speaker: {
155+
displayName: 'Participant 3',
156+
identifier: { communicationUserId: 'communicationId3', kind: 'communicationUser' as const }
157+
},
158+
spokenLanguage: 'ar-ae' as const,
159+
captionText: '!سُعدت برؤيتك'
160+
}
161+
],
162+
supportedSpokenLanguages: captionsAvailableLanguageStrings,
163+
supportedCaptionLanguages: captionsAvailableLanguageStrings,
164+
currentCaptionLanguage: 'ar-ae',
165+
currentSpokenLanguage: 'ar-ae',
166+
isCaptionsFeatureActive: true
167+
};
Loading
Loading
Loading

0 commit comments

Comments
 (0)