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 Apr 10, 2024
1 parent f8e6247 commit d838818
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,8 @@ function defaultPasteResolver({
const isSingleValuePasted = pastedData.length === 1 && pastedData[0].length === 1;

const cellSelectionModel = apiRef.current.getCellSelectionModel();
if (cellSelectionModel && apiRef.current.getSelectedCellsAsArray().length > 1) {
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 @@ -275,7 +276,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 d838818

Please sign in to comment.