Skip to content

Commit

Permalink
use selected cell if there's no focused cell
Browse files Browse the repository at this point in the history
  • Loading branch information
cherniavskii committed Apr 9, 2024
1 parent 9d049bb commit 732b708
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 732b708

Please sign in to comment.