Skip to content

Commit

Permalink
[DataGridPremium] Fix clipboard paste not working when cell loses foc…
Browse files Browse the repository at this point in the history
…us (#12724)
  • Loading branch information
cherniavskii authored and web-flow committed Apr 10, 2024
1 parent bd7ef17 commit bf1a30c
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,9 @@ function defaultPasteResolver({
}) {
const isSingleValuePasted = pastedData.length === 1 && pastedData[0].length === 1;

const cellSelectionModel = apiRef.current.unstable_getCellSelectionModel();
if (cellSelectionModel && apiRef.current.unstable_getSelectedCellsAsArray().length > 1) {
const cellSelectionModel = apiRef.current.getCellSelectionModel();
const selectedCellsArray = apiRef.current.getSelectedCellsAsArray();
if (cellSelectionModel && selectedCellsArray.length > 1) {
Object.keys(cellSelectionModel).forEach((rowId, rowIndex) => {
const rowDataArr = pastedData[isSingleValuePasted ? 0 : rowIndex];
const hasRowData = isSingleValuePasted ? true : rowDataArr !== undefined;
Expand Down Expand Up @@ -276,7 +277,11 @@ function defaultPasteResolver({
return;
}

const selectedCell = gridFocusCellSelector(apiRef);
let selectedCell = gridFocusCellSelector(apiRef);
if (!selectedCell && selectedCellsArray.length === 1) {
selectedCell = selectedCellsArray[0];
}

if (!selectedCell) {
return;
}
Expand Down

0 comments on commit bf1a30c

Please sign in to comment.