Skip to content

Commit

Permalink
CB-4698 fix: limit grid inline editor
Browse files Browse the repository at this point in the history
  • Loading branch information
Wroud committed May 13, 2024
1 parent c8ec571 commit 51695db
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ function isAtBottom(event: React.UIEvent<HTMLDivElement>): boolean {

const rowHeight = 25;
const headerHeight = 28;
const MAX_CELL_TEXT_SIZE = 100 * 1024;

export const DataGridTable = observer<IDataPresentationProps<any, IDatabaseResultSet>>(function DataGridTable({
model,
Expand Down Expand Up @@ -82,6 +83,7 @@ export const DataGridTable = observer<IDataPresentationProps<any, IDatabaseResul

const focusSyncRef = useRef<CellPosition | null>(null);

const tableData = useTableData(model, resultIndex, dataGridDivRef);
const editingContext = useEditing({
readonly: model.isReadonly(resultIndex) || model.isDisabled(resultIndex),
onEdit: (position, code, key) => {
Expand Down Expand Up @@ -114,14 +116,21 @@ export const DataGridTable = observer<IDataPresentationProps<any, IDatabaseResul
}
}

const isTruncated = tableData.dataContent.isTextTruncated(cellKey) || tableData.dataContent.isBlobTruncated(cellKey);
const isHugeText = tableData.format.getText(cellKey).length > MAX_CELL_TEXT_SIZE;

if (isHugeText || isTruncated) {
actions.setValuePresentation('value-text-presentation');
return false;
}

return true;
},
onCloseEditor: () => {
restoreFocus();
},
});

const tableData = useTableData(model, resultIndex, dataGridDivRef);
const gridSelectionContext = useGridSelectionContext(tableData, selectionAction);

function restoreFocus() {
Expand Down

0 comments on commit 51695db

Please sign in to comment.