Skip to content
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
4819a2e
Update MessageThread.styles.ts
jpeng-ms Jul 11, 2024
b6ae619
Merge branch 'main' into john/loading-img-fix
jpeng-ms Jul 11, 2024
e274fa0
Change files
jpeng-ms Jul 11, 2024
9a2cbfb
Merge branch 'main' into john/loading-img-fix
jpeng-ms Jul 11, 2024
e5319e7
Update packages/react-components browser test snapshots
github-actions[bot] Jul 11, 2024
3cc9bd9
Update ChatScreen.tsx
jpeng-ms Jul 11, 2024
bd94212
Merge branch 'john/loading-img-fix' of https://github.com/Azure/commu…
jpeng-ms Jul 11, 2024
278e835
Update packages/react-composites ChatComposite browser test snapshots
github-actions[bot] Jul 11, 2024
699a018
Merge branch 'john/loading-img-fix' of https://github.com/Azure/commu…
github-actions[bot] Jul 11, 2024
ce2f340
Update packages/react-composites ChatComposite browser test snapshots
github-actions[bot] Jul 11, 2024
a33051f
Merge branch 'john/loading-img-fix' of https://github.com/Azure/commu…
github-actions[bot] Jul 11, 2024
01b21b1
update
jpeng-ms Jul 11, 2024
969b996
updated samples
jpeng-ms Jul 11, 2024
b457a3e
Update packages/react-components browser test snapshots
github-actions[bot] Jul 11, 2024
826aaa5
Merge branch 'main' into john/loading-img-fix
jpeng-ms Jul 12, 2024
49588cf
updated samples
jpeng-ms Jul 12, 2024
6be2a2a
Merge branch 'main' into john/loading-img-fix
jpeng-ms Jul 15, 2024
df1fef2
Update MessageThread.styles.ts
jpeng-ms Jul 15, 2024
f501527
Merge branch 'john/loading-img-fix' of https://github.com/Azure/commu…
jpeng-ms Jul 15, 2024
34cf333
Merge branch 'main' into john/loading-img-fix
jpeng-ms Jul 15, 2024
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
@@ -0,0 +1,9 @@
{
"type": "patch",
"area": "fix",
"workstream": "Inline Image",
"comment": "Fixed the issue where image loading placeholder doesn't work for safari",
"packageName": "@azure/communication-react",
"email": "109105353+jpeng-ms@users.noreply.github.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"type": "patch",
"area": "fix",
"workstream": "Inline Image",
"comment": "Fixed the issue where image loading placeholder doesn't work for safari",
"packageName": "@azure/communication-react",
"email": "109105353+jpeng-ms@users.noreply.github.com",
"dependentChangeType": "patch"
}
11 changes: 11 additions & 0 deletions packages/chat-component-bindings/src/messageThreadSelector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ const processChatMessageContent = (message: ChatMessageWithStatus): string | und
// else in loading or success state
img.setAttribute('src', src);
}
setImageWidthAndHeight(img);
}
});
content = document.body.innerHTML;
Expand Down Expand Up @@ -208,6 +209,16 @@ const extractAttachmentContentTypeFromName = (name?: string): string => {
return contentType;
};

const setImageWidthAndHeight = (img?: HTMLImageElement): void => {
if (img) {
// define aspect ratio explicitly to prevent image not being displayed correctly
// in safari, this includes image placeholder for loading state
const width = img.width;
const height = img.height;
img.style.aspectRatio = `${width}/${height}`;
}
};

/* @conditional-compile-remove(file-sharing-teams-interop) @conditional-compile-remove(file-sharing-acs) */
const extractAttachmentsMetadata = (message: ChatMessageWithStatus): { attachments?: AttachmentMetadata[] } => {
let attachments: AttachmentMetadata[] = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,9 +357,11 @@ export const useChatMessageCommonStyles = makeStyles({
},
bodyWithPlaceholderImage: {
'& img[src=""]': {
display: 'block',
fontSize: '0',
Comment thread
jpeng-ms marked this conversation as resolved.
Outdated
backgroundColor: tokens.colorNeutralBackground1Selected,
position: 'relative',
marginBottom: '5px'
clipPath: 'inset(0.3px)',
display: 'flex'
},
'& img[src=""]:after': {
backgroundColor: tokens.colorNeutralBackground1Selected,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ betaTest.describe('ImageOverlay tests', () => {
messageType: 'chat',
senderId: 'user3',
content:
'<p>How should I design my new house?</p><p><img alt="image" src="images/inlineImageExample1.png" itemscope="png" width="166.5625" height="250" id="SomeImageId1" style="vertical-align:bottom"></p><p><img alt="image" src="images/inlineImageExample2.png" itemscope="png" width="374.53183520599254" height="250" id="SomeImageId2" style="vertical-align:bottom"></p><p>&nbsp;</p>',
'<p>How should I design my new house?</p><p><img alt="image" src="images/inlineImageExample1.png" itemscope="png" width="166" height="250" id="SomeImageId1" style="vertical-align:bottom; aspect-ratio: 166 / 250;"></p><p><img alt="image" src="images/inlineImageExample2.png" itemscope="png" width="374" height="250" id="SomeImageId2" style="vertical-align:bottom; aspect-ratio: 374 / 250"></p><p>&nbsp;</p>',
senderDisplayName: 'Miguel Garcia',
messageId: Math.random().toString(),
createdOn: new Date('2019-04-13T00:00:00.000+08:09'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ betaTest.describe('MessageThread inline image tests', () => {
{
messageType: 'chat',
senderId: 'user3',
content: `<p>How should I design my new house?</p><p><img alt="image" src="${imgSrc}" itemscope="png" width="374.53183520599254" height="250" id="SomeImageId2" style="vertical-align:bottom"></p><p>&nbsp;</p>`,
content: `<p>How should I design my new house?</p><p><img alt="image" src="${imgSrc}" itemscope="png" width="374" height="250" id="SomeImageId2" style="vertical-align:bottom; aspect-ratio: 374 / 250"></p><p>&nbsp;</p>`,
senderDisplayName: 'Miguel Garcia',
messageId: Math.random().toString(),
createdOn: new Date('2019-04-13T00:00:00.000+08:09'),
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.
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ const sendRemoteInlineImageMessage = (
sequenceId: `${thread.messages.length}`,
version: '0',
content: {
message: `<p>Test</p><p><img alt="image" src="${imgSrcPreview}" itemscope="png" width="200" height="300" id="SomeImageId1" style="vertical-align:bottom"></p><p>&nbsp;</p>`,
message: `<p>Test</p><p><img alt="image" src="${imgSrcPreview}" itemscope="png" width="200" height="300" id="SomeImageId1" style="vertical-align:bottom; aspect-ratio: 200 / 300;"></p><p>&nbsp;</p>`,
attachments: [
{
id: 'SomeImageId1',
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.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export const GenerateMockNewChatMessageWithInlineImage = (): ChatMessage => {
...UserThree,
messageId: Math.random().toString(),
content:
'<p>Check out this image:&nbsp;</p>\r\n<p><img alt="image" src="images/inlineImageExample1.png" itemscope="png" width="250" height="375" id="SomeImageId" style="vertical-align:bottom"></p><p>&nbsp;</p>\r\n',
'<p>Check out this image:&nbsp;</p>\r\n<p><img alt="image" src="images/inlineImageExample1.png" itemscope="png" width="250" height="375" id="SomeImageId" style="vertical-align:bottom; aspect-ratio: 250 / 375;"></p><p>&nbsp;</p>\r\n',
createdOn: new Date('2020-04-13T00:00:00.000+07:01'),
mine: false,
attached: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export const MessageThreadWithInlineImageExample: () => JSX.Element = () => {
messageType: 'chat',
senderId: 'user3',
content:
'<p>How should I design my new house?</p><p><img alt="image" src="images/inlineImageExample1.png" itemscope="png" width="166.5625" height="250" id="SomeImageId1" style="vertical-align:bottom"></p><p><img alt="image" src="images/inlineImageExample2.png" itemscope="png" width="374.53183520599254" height="250" id="SomeImageId2" style="vertical-align:bottom"></p><p>&nbsp;</p>',
'<p>How should I design my new house?</p><p><img alt="image" src="images/inlineImageExample1.png" itemscope="png" width="166" height="250" id="SomeImageId1" style="vertical-align:bottom; aspect-ratio: 166 / 250"></p><p><img alt="image" src="images/inlineImageExample2.png" itemscope="png" width="374" height="250" id="SomeImageId2" style="vertical-align:bottom; aspect-ratio: 374 / 250"></p><p>&nbsp;</p>',
senderDisplayName: 'Miguel Garcia',
messageId: Math.random().toString(),
createdOn: new Date('2019-04-13T00:00:00.000+08:09'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export const GenerateMockNewChatMessageWithInlineImage = (): ChatMessage => {
...UserThree,
messageId: Math.random().toString(),
content:
'<p>Check out this image:&nbsp;</p>\r\n<p><img alt="image" src="images/inlineImageExample1.png" itemscope="png" width="250" height="375" id="SomeImageId" style="vertical-align:bottom"></p><p>&nbsp;</p>\r\n',
'<p>Check out this image:&nbsp;</p>\r\n<p><img alt="image" src="images/inlineImageExample1.png" itemscope="png" width="250" height="375" id="SomeImageId" style="vertical-align:bottom; aspect-ratio: 250 / 375;"></p><p>&nbsp;</p>\r\n',
createdOn: new Date('2020-04-13T00:00:00.000+07:01'),
mine: false,
attached: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export const MessageThreadWithInlineImageExample: () => JSX.Element = () => {
messageType: 'chat',
senderId: 'user3',
content:
'<p>How should I design my new house?</p><p><img alt="image" src="images/inlineImageExample1.png" itemscope="png" width="166.5625" height="250" id="SomeImageId1" style="vertical-align:bottom"></p><p><img alt="image" src="images/inlineImageExample2.png" itemscope="png" width="374.53183520599254" height="250" id="SomeImageId2" style="vertical-align:bottom"></p><p>&nbsp;</p>',
'<p>How should I design my new house?</p><p><img alt="image" src="images/inlineImageExample1.png" itemscope="png" width="166" height="250" id="SomeImageId1" style="vertical-align:bottom; aspect-ratio: 166 / 250"></p><p><img alt="image" src="images/inlineImageExample2.png" itemscope="png" width="374" height="250" id="SomeImageId2" style="vertical-align:bottom; aspect-ratio: 374 / 250"></p><p>&nbsp;</p>',
senderDisplayName: 'Miguel Garcia',
messageId: Math.random().toString(),
createdOn: new Date('2019-04-13T00:00:00.000+08:09'),
Expand Down