Comments (9)
I had a similar kind of Issue when deleting a row. I got all new records deleted and found that tableData was in the initial state in the renderRowActions
delete function even though the table shows correct data. later I found that if we set displayColumnDefOptions
prop even with an empty object issue got fixed. This is a strange way but I thought it will help to fix the issue.
from material-react-table.
@udithsc thanks a lot. I had the exact same problem and it was driving me nuts.
I confirm that setting the displayColumnDefOptions prop solves the issue
from material-react-table.
I am having a similar problem. In my case, when I delete a row, it's always the last row that gets deleted (visually).
I found out that the problem is with the table editing mode. It seems to me that MRT_EditCellTextField
is not handling cell value changes, as it only gets the cell value to initialize the value
state (by using the useState
hook).
from material-react-table.
The problem is a unique key for each row is the index, which is the default behavior.
. Therefore you should tell the material-react-table about the unique key for each row by using getRowId method
For example: if the unique key of the row is userId,
you can use the following code:
<MaterialReactTable
getRowId={(originalRow) => {return originalRow.userId }}
editingMode="table"
{...rest}
/>
from material-react-table.
What I think is happening is that displayColumns is being memoized.
This memoization is deep, it includes MRT_ToggleRowActionMenuButton > MRT_EditActionButtons > handleSave > onEditingRowSave. It'll cache the references used in onEditingRowSave and keep using those unless something changes in the useMemo dependency array.
The prop "displayColumnDefOptions" is a dependency, by setting to an empty inline object you're essentially disabling the useMemo, since an inline object will be a new reference every render, it'd work with any other dependency that's an object (for example: localization).
Here's a codesandbox to see what useMemo does to states you want to use inside your functions.
The reason the demo page for editing works is that the original data reference is being modified before it's copied.
from material-react-table.
All of my own editing examples, which are supposed to do the same thing here, are working fine. You will need to create a full sandbox demoing the issue you are running into here.
My guess is that pasteContent
is using the wrong data structures and not actually adding a new row to the table.
renderRowActions
has this type signature: ({ cell, row, table }) => ReactNode
, not the (row, index) one that you are trying to use.
from material-react-table.
I am having a similar problem. In my case, when I delete a row, it's always the last row that gets deleted (visually).
I found out that the problem is with the table editing mode. It seems to me that
MRT_EditCellTextField
is not handling cell value changes, as it only gets the cell value to initialize thevalue
state (by using theuseState
hook).
Need to look into this. Yes makes sense that the input text state is the root of the problem.
from material-react-table.
Having the same issue, even when setting the prop <MaterialReactTable displayColumnDefOptions={{}} editingMode="table" ... />
, I'm using material-react-table version 1.8.5
.
I switched to the editingMode="cell"
type instead of editingMode="table"
; I guess I'll change back to table
once this is resolved.
from material-react-table.
This might be all the way fixed in v2.9.0 as columns are no longer memoized internally except during resizing and dragging events.
from material-react-table.
Related Issues (20)
- Really strange issue HOT 7
- Localisation of filters does not apply to the filter menu HOT 1
- Show/hide filter triggers onColumnFiltersChange for backend pagination HOT 4
- "Show filter" triggers onColumnFiltersChange for backend pagination
- Mantine Filter Search Does Not Work Correctly and Highlight Words When Turkish Characters Are Used with Capslock On. HOT 2
- Virtualization is not working properly even on the documentation page! HOT 5
- Sticky Pinned Columns Misplacement in Material React Table for RTL Language
- MRT_TablePaper zIndex is lower than Appbar in Fullscreen
- Pinned columns collapsing even with layoutMode: 'grid-no-grow'
- Drag row exception when row virtualization is true HOT 1
- Header title has been dissapear from v10 to v11 HOT 1
- Pagination Container Box gets cut off when default font size is not 16px HOT 1
- [BUG] - Sub Row Selection not working correctly
- Mui palette theme problem HOT 1
- react-query/sandbox does not work properly in codesandbox.io
- Tooltip on FullScreenButton not showing on focus HOT 1
- Getting Error while loading TS.tsx HOT 2
- onSortingChange getting called twice on first render
- positionCreatingRow is been ignored
- Data does not refresh when using editDisplayMode: 'table' HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from material-react-table.