@opengeni/react 2.5.0-canary.0 → 2.5.0-canary.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.
@@ -2883,6 +2883,7 @@ import {
2883
2883
  useContext,
2884
2884
  useEffect as useEffect3,
2885
2885
  useId as useId2,
2886
+ useLayoutEffect,
2886
2887
  useMemo as useMemo4,
2887
2888
  useRef as useRef4,
2888
2889
  useState as useState4
@@ -3047,6 +3048,28 @@ function useChatComposerController({
3047
3048
  const submittingRef = useRef4(false);
3048
3049
  const controlOperationRef = useRef4(false);
3049
3050
  const mountedRef = useRef4(true);
3051
+ const deliveredValueRef = useRef4(delivery.value);
3052
+ const liveValueRef = useRef4(delivery.value);
3053
+ const [renderedValue, setRenderedValue] = useState4(delivery.value);
3054
+ const deliveryChanged = delivery.value !== deliveredValueRef.current;
3055
+ if (deliveryChanged) {
3056
+ deliveredValueRef.current = delivery.value;
3057
+ liveValueRef.current = delivery.value;
3058
+ }
3059
+ const setComposerValue = useCallback4(
3060
+ (next) => {
3061
+ liveValueRef.current = next;
3062
+ setRenderedValue(next);
3063
+ delivery.setValue(next);
3064
+ },
3065
+ [delivery.setValue]
3066
+ );
3067
+ const visibleValue = deliveryChanged ? delivery.value : renderedValue;
3068
+ useLayoutEffect(() => {
3069
+ if (renderedValue !== liveValueRef.current) {
3070
+ setRenderedValue(liveValueRef.current);
3071
+ }
3072
+ }, [delivery.value, renderedValue]);
3050
3073
  useEffect3(() => {
3051
3074
  mountedRef.current = true;
3052
3075
  return () => {
@@ -3131,7 +3154,7 @@ function useChatComposerController({
3131
3154
  applyComposerTextareaHeight(textarea, 220);
3132
3155
  });
3133
3156
  }, []);
3134
- useEffect3(() => resizeInput(), [delivery.value, resizeInput]);
3157
+ useEffect3(() => resizeInput(), [resizeInput, visibleValue]);
3135
3158
  useEffect3(
3136
3159
  () => () => {
3137
3160
  if (resizeInputRafRef.current !== null) {
@@ -3165,8 +3188,8 @@ function useChatComposerController({
3165
3188
  commands,
3166
3189
  context: commandContext,
3167
3190
  handlers,
3168
- value: delivery.value,
3169
- setValue: delivery.setValue
3191
+ value: visibleValue,
3192
+ setValue: setComposerValue
3170
3193
  });
3171
3194
  const paletteEnabled = commandContext !== void 0;
3172
3195
  const commandDraftBlocked = paletteEnabled && palette.isCommandDraft;
@@ -3330,8 +3353,8 @@ function useChatComposerController({
3330
3353
  handlePaste,
3331
3354
  handleFileChange,
3332
3355
  focusInput: () => textareaRef.current?.focus(),
3333
- setValue: delivery.setValue,
3334
- value: delivery.value
3356
+ setValue: setComposerValue,
3357
+ value: visibleValue
3335
3358
  };
3336
3359
  }
3337
3360
  var ComposerContext = createContext(null);
@@ -4531,4 +4554,4 @@ export {
4531
4554
  Status,
4532
4555
  ComposerTranscriptionControl
4533
4556
  };
4534
- //# sourceMappingURL=chunk-NVREJA6V.js.map
4557
+ //# sourceMappingURL=chunk-ZUT5QSQB.js.map