diff --git a/client/packages/lowcoder/src/components/table/EditableCell.tsx b/client/packages/lowcoder/src/components/table/EditableCell.tsx index 3e68cfdff..f8f9ebe16 100644 --- a/client/packages/lowcoder/src/components/table/EditableCell.tsx +++ b/client/packages/lowcoder/src/components/table/EditableCell.tsx @@ -37,6 +37,7 @@ export interface CellProps { candidateStatus?: { text: string; status: StatusType }[]; textOverflow?: boolean; cellTooltip?: string; + editMode?: string; onTableEvent?: (eventName: any) => void; } @@ -94,6 +95,7 @@ export function EditableCell(props: EditableCellProps) { candidateTags, // tagColors candidateStatus, + editMode, onTableEvent, } = props; const status = _.isNil(changeValue) ? "normal" : "toSave"; @@ -101,10 +103,11 @@ export function EditableCell(props: EditableCellProps) { const { isEditing, setIsEditing } = useContext(TableCellContext); const value = changeValue ?? baseValue!; const [tmpValue, setTmpValue] = useState(value); + const singleClickEdit = editMode === 'single'; useEffect(() => { setTmpValue(value); - }, [value]); + }, [JSON.stringify(value)]); const onChange = useCallback( (value: T) => { @@ -125,11 +128,13 @@ export function EditableCell(props: EditableCellProps) { if(!_.isEqual(tmpValue, value)) { onTableEvent?.('columnEdited'); } - }, [dispatch, baseValue, tmpValue]); + }, [dispatch, JSON.stringify(baseValue), JSON.stringify(tmpValue)]); + const editView = useMemo( () => editViewFn?.({ value, onChange, onChangeEnd }) ?? <>, - [editViewFn, value, onChange, onChangeEnd] + [editViewFn, JSON.stringify(value), onChange, onChangeEnd] ); + const enterEditFn = useCallback(() => { if (editable) setIsEditing(true); }, [editable]); @@ -137,9 +142,13 @@ export function EditableCell(props: EditableCellProps) { if (isEditing) { return ( <> - + - {editView} + +
+ {editView} +
+
); @@ -151,7 +160,12 @@ export function EditableCell(props: EditableCellProps) { > {status === "toSave" && !isEditing && } - {normalView} +
+ {normalView} +
{/* overlay on normal view to handle double click for editing */} {editable && ( @@ -164,7 +178,8 @@ export function EditableCell(props: EditableCellProps) { width: '100%', height: '100%', }} - onDoubleClick={enterEditFn} + onDoubleClick={!singleClickEdit ? enterEditFn : undefined} + onClick={singleClickEdit ? enterEditFn : undefined} > diff --git a/client/packages/lowcoder/src/comps/comps/selectInputComp/selectCompConstants.tsx b/client/packages/lowcoder/src/comps/comps/selectInputComp/selectCompConstants.tsx index 41851324f..360a68460 100644 --- a/client/packages/lowcoder/src/comps/comps/selectInputComp/selectCompConstants.tsx +++ b/client/packages/lowcoder/src/comps/comps/selectInputComp/selectCompConstants.tsx @@ -253,10 +253,12 @@ export const SelectUIView = ( inputFieldStyle: SelectStyleType; onChange: (value: any) => void; dispatch: DispatchType; + autoFocus?: boolean; } ) => { return