Skip to content

Commit b45490e

Browse files
authored
Resolve issue where RichTextBox could not be found when running in production with a minimized bundle (#5712)
* Resolve issue where RichTextBox could not be found when running in production with a minimized bundle. * Avoid using public API * Add cc * Change files * Use unknown instead * Any * Temp disable lint * Fix tree shaking * Revert * Move to another file * Fix tree shaking * Export Symbol * Clean up logging * Comments * Lint and CC * Address comments * Updating identifier name * Update with internal name
1 parent bed031e commit b45490e

6 files changed

Lines changed: 55 additions & 1 deletion

File tree

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"type": "patch",
3+
"area": "fix",
4+
"workstream": "",
5+
"comment": "Resolve issue where RichTextBox could not be found when running in production with a minimized bundle.",
6+
"packageName": "@azure/communication-react",
7+
"email": "palatter@microsoft.com",
8+
"dependentChangeType": "patch"
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"type": "patch",
3+
"area": "fix",
4+
"workstream": "",
5+
"comment": "Resolve issue where RichTextBox could not be found when running in production with a minimized bundle.",
6+
"packageName": "@azure/communication-react",
7+
"email": "palatter@microsoft.com",
8+
"dependentChangeType": "patch"
9+
}

packages/chat-component-bindings/src/hooks/usePropsFor.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import { ErrorBar, MessageThread, ParticipantList, SendBox, TypingIndicator } fr
44

55
/* @conditional-compile-remove(rich-text-editor) */
66
import type { RichTextSendBox } from '@internal/react-components';
7+
/* @conditional-compile-remove(rich-text-editor) */
8+
import { _isRichTextSendBox } from '@internal/react-components';
79

810
import { useHandlers } from './useHandlers';
911
import { useSelector } from './useSelector';
@@ -98,10 +100,14 @@ const findSelector = (component: (props: any) => JSX.Element | undefined): any =
98100
}
99101
return messageThreadSelectorImpl;
100102
};
103+
104+
// Add component type check to assist in identification for usePropsFor
105+
// to avoid issue where production build does not have the component name
101106
/* @conditional-compile-remove(rich-text-editor) */
102-
if (typeof component === 'function' && component.name === 'RichTextSendBox') {
107+
if (_isRichTextSendBox(component)) {
103108
return sendBoxSelector;
104109
}
110+
105111
switch (component) {
106112
case SendBox:
107113
return sendBoxSelector;

packages/react-components/src/components/RichTextEditor/RichTextSendBox.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ import { SendBoxErrorBarType } from '../SendBoxErrorBar';
4040
import { attachmentUploadCardsStyles } from '../styles/SendBox.styles';
4141
/* @conditional-compile-remove(file-sharing-acs) */
4242
import { FluentV9ThemeProvider } from '../../theming/FluentV9ThemeProvider';
43+
/* @conditional-compile-remove(rich-text-editor) */
44+
import { richTextSendBoxIdentifier } from './RichTextSendBoxUtils';
4345

4446
/**
4547
* Strings of {@link RichTextSendBox} that can be overridden.
@@ -597,3 +599,9 @@ export const RichTextSendBox = (props: RichTextSendBoxProps): JSX.Element => {
597599
</Stack>
598600
);
599601
};
602+
603+
/* @conditional-compile-remove(rich-text-editor) */
604+
// Add component type check to assist in identification for usePropsFor
605+
// to avoid issue where production build does not have the component name
606+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
607+
(RichTextSendBox as any)[richTextSendBoxIdentifier] = true;
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT License.
3+
4+
// Add component type check to assist in identification for usePropsFor
5+
// to avoid issue where production build does not have the component name
6+
7+
/* @conditional-compile-remove(rich-text-editor) */
8+
/**
9+
* @private
10+
*/
11+
export const richTextSendBoxIdentifier = Symbol('richTextSendBoxIdentifier');
12+
13+
/* @conditional-compile-remove(rich-text-editor) */
14+
/**
15+
* @internal
16+
*/
17+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
18+
export const _isRichTextSendBox = (component: any): boolean => {
19+
return component?.[richTextSendBoxIdentifier] === true;
20+
};

packages/react-components/src/components/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ export type { SendBoxProps, SendBoxStrings, SendBoxStylesProps } from './SendBox
2020

2121
/* @conditional-compile-remove(rich-text-editor) */
2222
export { RichTextSendBox } from './RichTextEditor/RichTextSendBox';
23+
/* @conditional-compile-remove(rich-text-editor) */
24+
export { _isRichTextSendBox } from './RichTextEditor/RichTextSendBoxUtils';
2325
// TODO: This component is exported only for testing purposes. Remove this when this component is added to composites
2426
/* @conditional-compile-remove(rich-text-editor) */
2527
export { ChatMessageComponentAsRichTextEditBox } from './ChatMessage/MyMessageComponents/ChatMessageComponentAsRichTextEditBox';

0 commit comments

Comments
 (0)