Skip to content

The open alternative to Salesforce, designed for AI.

Fix text input bug (#544)

Lucas Bordeau09efc49ef2e2
diff --git a/front/src/modules/ui/components/editable-cell/types/EditableCellText.tsx b/front/src/modules/ui/components/editable-cell/types/EditableCellText.tsx
index 9b54641f0a9..a0edcfc4cdb 100644
--- a/front/src/modules/ui/components/editable-cell/types/EditableCellText.tsx
+++ b/front/src/modules/ui/components/editable-cell/types/EditableCellText.tsx
@@ -1,7 +1,8 @@
-import { ChangeEvent } from 'react';
+import { ChangeEvent, useMemo, useState } from 'react';
import { InplaceInputTextDisplayMode } from '@/ui/inplace-inputs/components/InplaceInputTextDisplayMode';
import { InplaceInputTextEditMode } from '@/ui/inplace-inputs/components/InplaceInputTextEditMode';
+import { debounce } from '@/utils/debounce';
import { EditableCell } from '../EditableCell';
@@ -18,6 +19,12 @@ export function EditableCellText({
onChange,
editModeHorizontalAlign,
}: OwnProps) {
+ const [internalValue, setInternalValue] = useState(value);
+
+ const debouncedOnChange = useMemo(() => {
+ return debounce(onChange, 200);
+ }, [onChange]);
+
return (
<EditableCell
editModeHorizontalAlign={editModeHorizontalAlign}
@@ -25,14 +32,17 @@ export function EditableCellText({
<InplaceInputTextEditMode
placeholder={placeholder || ''}
autoFocus
- value={value}
+ value={internalValue}
onChange={(event: ChangeEvent<HTMLInputElement>) => {
- onChange(event.target.value);
+ setInternalValue(event.target.value);
+ debouncedOnChange(event.target.value);
}}
/>
}
nonEditModeContent={
- <InplaceInputTextDisplayMode>{value}</InplaceInputTextDisplayMode>
+ <InplaceInputTextDisplayMode>
+ {internalValue}
+ </InplaceInputTextDisplayMode>
}
></EditableCell>
);