Open ikzhr opened 7 months ago
I think I understand the cause and how to fix it, so if it is considered a bug, I will create a PR to fix it.
The cause is that the update process (updateCell) during paste only refers to the editable property of the column.
apiRef.current.getCellParams(rowId, field).isEditable
takes into account both the column settings and the control of the isCellEditable prop, so I think this property should be used to determine if an update should be applied.
Hey @ikzhr ... thanks for raising this issue. IMHO this should be considered a bug, but would like to ask @joserodolfofreitas for his opinion!
I confirm it's a bug - clipboard paste doesn't use the isCellEditable
prop while it should.
@ikzhr If you're willing to open a PR - instead of using getCellParams().isEditable
you can call isCellEditable
directly. This will be faster, because getCellParams
also calls valueFormatter
that we don't need for the clipboard paste.
@cherniavskii @michelengelen Thanks, I'll try to fix it.
Steps to reproduce
Link to live example: https://codesandbox.io/p/devbox/pm4zm7?file=%2Fsrc%2FDemo.tsx%3A33%2C36&layout=%257B[…]ebar%2522%253Atrue%252C%2522sidebarPanelSize%2522%253A15%257D
Notes on example:
isCellEditable
prop that always returnsfalse
Steps:
Ctrl+C
to copy any cell,Ctrl+V
to paste into another cellCurrent behavior
Paste operation can overwrite the contents of non-editable cells.
Expected behavior
Paste operation can NOT overwrite the contents of non-editable cells.
Context
No response
Your environment
``` System: OS: macOS 13.3.1 Binaries: Node: 16.15.1 - ~/.anyenv/envs/nodenv/versions/16.15.1/bin/node npm: 8.11.0 - ~/.anyenv/envs/nodenv/versions/16.15.1/bin/npm pnpm: Not Found Browsers: Chrome: 121.0.6167.139 ⭐ My default browser Edge: 121.0.2277.106 Safari: 16.4 ```npx @mui/envinfo
Search keywords: DataGridPremium paste non-editable Order ID: 74090