stream-chat-react 13.6.1 → 13.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -24,7 +24,7 @@ export const useChat = ({ client, defaultLanguage = 'en', i18nInstance, initialN
24
24
  useEffect(() => {
25
25
  if (!client)
26
26
  return;
27
- const version = "13.6.1";
27
+ const version = "13.6.2";
28
28
  const userAgent = client.getUserAgent();
29
29
  if (!userAgent.includes('stream-chat-react')) {
30
30
  // result looks like: 'stream-chat-react-2.3.2-stream-chat-javascript-client-browser-2.2.2'
@@ -160,6 +160,16 @@ export const TextareaComposer = ({ className, closeSuggestionsOnClickOutside, co
160
160
  const textarea = textareaRef.current;
161
161
  if (!textarea || isComposing)
162
162
  return;
163
+ /**
164
+ * The textarea value has to be overridden outside the render cycle so that the events like compositionend can be triggered.
165
+ * If we have overridden the value during the component rendering, the compositionend event would not be triggered, and
166
+ * it would not be possible to type composed characters (ô).
167
+ * On the other hand, just removing the value override via prop (value={text}) would not allow us to change the text based on
168
+ * middleware results (e.g. replace characters with emojis)
169
+ */
170
+ if (textarea.value !== text) {
171
+ textarea.value = text;
172
+ }
163
173
  const length = textarea.value.length;
164
174
  const start = Math.max(0, Math.min(selection.start, length));
165
175
  const end = Math.max(start, Math.min(selection.end, length));
@@ -172,6 +182,6 @@ export const TextareaComposer = ({ className, closeSuggestionsOnClickOutside, co
172
182
  }), ref: containerRef },
173
183
  React.createElement(Textarea, { ...additionalTextareaProps, ...restTextareaProps, "aria-label": cooldownRemaining ? t('Slow Mode ON') : placeholder, className: clsx('rta__textarea', 'str-chat__textarea__textarea str-chat__message-textarea', className), "data-testid": 'message-input', disabled: !enabled || !!cooldownRemaining, maxRows: maxRows, minRows: minRows, onBlur: onBlur, onChange: changeHandler, onCompositionEnd: onCompositionEnd, onCompositionStart: onCompositionStart, onKeyDown: keyDownHandler, onPaste: onPaste, onScroll: scrollHandler, onSelect: setSelection, placeholder: placeholder || t('Type your message'), ref: (ref) => {
174
184
  textareaRef.current = ref;
175
- }, value: text }),
185
+ } }),
176
186
  !isComposing && (React.createElement(AutocompleteSuggestionList, { className: listClassName, closeOnClickOutside: closeSuggestionsOnClickOutside, focusedItemIndex: focusedItemIndex, setFocusedItemIndex: setFocusedItemIndex }))));
177
187
  };
@@ -33454,6 +33454,9 @@ var TextareaComposer = ({
33454
33454
  (0, import_react255.useLayoutEffect)(() => {
33455
33455
  const textarea = textareaRef.current;
33456
33456
  if (!textarea || isComposing) return;
33457
+ if (textarea.value !== text7) {
33458
+ textarea.value = text7;
33459
+ }
33457
33460
  const length = textarea.value.length;
33458
33461
  const start2 = Math.max(0, Math.min(selection.start, length));
33459
33462
  const end = Math.max(start2, Math.min(selection.end, length));
@@ -33498,8 +33501,7 @@ var TextareaComposer = ({
33498
33501
  placeholder: placeholder || t("Type your message"),
33499
33502
  ref: (ref) => {
33500
33503
  textareaRef.current = ref;
33501
- },
33502
- value: text7
33504
+ }
33503
33505
  }
33504
33506
  ),
33505
33507
  !isComposing && /* @__PURE__ */ import_react255.default.createElement(
@@ -36115,7 +36117,7 @@ var useChat = ({
36115
36117
  };
36116
36118
  (0, import_react282.useEffect)(() => {
36117
36119
  if (!client) return;
36118
- const version = "13.6.1";
36120
+ const version = "13.6.2";
36119
36121
  const userAgent = client.getUserAgent();
36120
36122
  if (!userAgent.includes("stream-chat-react")) {
36121
36123
  client.setUserAgent(`stream-chat-react-${version}-${userAgent}`);