mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-10-29 18:03:45 +08:00
fix(plugin-data-spreadsheet): CB-527 cell editing
This commit is contained in:
@@ -20,7 +20,8 @@ import {
|
||||
GridOptions,
|
||||
CellClassParams,
|
||||
SortChangedEvent,
|
||||
RowNode
|
||||
RowNode,
|
||||
CellEditingStoppedEvent
|
||||
} from '@ag-grid-community/core';
|
||||
import { injectable, IInitializableController, IDestructibleController } from '@cloudbeaver/core-di';
|
||||
import {
|
||||
@@ -75,6 +76,7 @@ export class AgGridTableController implements IInitializableController, IDestruc
|
||||
onBodyScroll: this.handleBodyScroll.bind(this),
|
||||
|
||||
onSortChanged: this.handleSortChanged.bind(this),
|
||||
onCellEditingStopped: this.handleCellEditingStopped.bind(this),
|
||||
};
|
||||
|
||||
@observable columns: ColDef[] = [];
|
||||
@@ -129,7 +131,6 @@ export class AgGridTableController implements IInitializableController, IDestruc
|
||||
startRow,
|
||||
endRow,
|
||||
successCallback,
|
||||
sortModel,
|
||||
failCallback,
|
||||
} = params;
|
||||
|
||||
@@ -232,6 +233,10 @@ export class AgGridTableController implements IInitializableController, IDestruc
|
||||
}
|
||||
}
|
||||
|
||||
private handleCellEditingStopped(event: CellEditingStoppedEvent) {
|
||||
this.gridModel.onCellEditingStopped(event.rowIndex, event.column.getId(), event.value, false);
|
||||
}
|
||||
|
||||
/* Actions */
|
||||
|
||||
private resetData(): void {
|
||||
|
||||
+8
-2
@@ -50,8 +50,6 @@ export const PlainTextEditor = forwardRef<Partial<ICellEditorComp>, ICellEditorP
|
||||
getValue: () => value.current,
|
||||
}), []);
|
||||
|
||||
useEffect(() => inputRef.current?.focus(), []);
|
||||
|
||||
const context: AgGridContext = props.context;
|
||||
|
||||
const handleSave = useCallback(() => props.stopEditing(), [props.stopEditing]);
|
||||
@@ -75,6 +73,14 @@ export const PlainTextEditor = forwardRef<Partial<ICellEditorComp>, ICellEditorP
|
||||
forceUpdate(value.current);
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
inputRef.current?.focus();
|
||||
|
||||
if (initValue !== props.value) {
|
||||
handleChange(initValue);
|
||||
}
|
||||
}, []);
|
||||
|
||||
const isLastColumn = props.columnApi?.getAllGridColumns().slice(-1)[0] === props.column;
|
||||
const isLastRow = props.rowIndex > 0 && ((props.api?.getInfiniteRowCount() || -1) - 1 === props.rowIndex);
|
||||
let controlsPosition: InlineEditorControls = 'right';
|
||||
|
||||
Reference in New Issue
Block a user