Skip to content

Commit d71776a

Browse files
Fix SendBox initialization that caused MaxListenersExceededWarning logs in the Console tool for ChatComposite with rich text editor enabled. (#5537)
1 parent f9f3d64 commit d71776a

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"type": "patch",
3+
"area": "fix",
4+
"workstream": "Chat",
5+
"comment": "Fix SendBox initialization that caused MaxListenersExceededWarning logs in the Console tool for ChatComposite with rich text editor enabled.",
6+
"packageName": "@azure/communication-react",
7+
"email": "[email protected]",
8+
"dependentChangeType": "patch"
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"type": "patch",
3+
"area": "fix",
4+
"workstream": "Chat",
5+
"comment": "Fix SendBox initialization that caused MaxListenersExceededWarning logs in the Console tool for ChatComposite with rich text editor enabled.",
6+
"packageName": "@azure/communication-react",
7+
"email": "[email protected]",
8+
"dependentChangeType": "patch"
9+
}

packages/react-composites/src/composites/common/SendBoxPicker.tsx

+8-3
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,12 @@ export const SendBoxPicker = (props: SendBoxPickerProps): JSX.Element => {
9292
/* @conditional-compile-remove(rich-text-editor-image-upload) */
9393
const { onPaste, onInsertInlineImage, inlineImagesWithProgress, onRemoveInlineImage } = richTextEditorOptions || {};
9494

95-
const sendBoxProps = usePropsFor(SendBox);
96-
9795
/* @conditional-compile-remove(rich-text-editor-composite-support) */
9896
const isRichTextEditorEnabled = useMemo(() => {
9997
return richTextEditorOptions !== undefined;
10098
}, [richTextEditorOptions]);
10199

102-
const sendBox = useMemo(() => <SendBox {...sendBoxProps} {...props} />, [props, sendBoxProps]);
100+
const sendBox = useMemo(() => <SendBoxWrapper {...props} />, [props]);
103101

104102
/* @conditional-compile-remove(rich-text-editor-composite-support) */
105103
if (isRichTextEditorEnabled) {
@@ -123,3 +121,10 @@ export const SendBoxPicker = (props: SendBoxPickerProps): JSX.Element => {
123121
}
124122
return sendBox;
125123
};
124+
125+
// Move SendBox initialization to a separate component as otherwise it will cause re-render for Suspense and _ErrorBoundary when props and sendBoxProps are updated
126+
const SendBoxWrapper = (props: SendBoxPickerProps): JSX.Element => {
127+
const sendBoxProps = usePropsFor(SendBox);
128+
129+
return <SendBox {...sendBoxProps} {...props} />;
130+
};

0 commit comments

Comments
 (0)