-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DataTable => Column: onCellEditComplete is fired twice #6141
Comments
looks like strict mode |
Any work around before the issue gets resolved? Thank you! |
The only workaround I found was to use
|
I have the same issue at 10.6.5 version but only onKeyDown. I was trying to debug it and see what is causing the function to be called twice but It seems to me that is something related with React... Could it be @melloware ? BTW, cellEditValidator is also being calld twice. In fact this code inside this function is what is being called twice when onKeyDown event is fired: primereact/components/lib/datatable/BodyCell.js Lines 167 to 196 in 463ba5c
The event is only fired once but the code inside The funny thing is that only happens if the value of the cell has been changed. Edit@kl-nevermore has right. I just found this issue on stackoverflow: https://stackoverflow.com/questions/62106596/reactjs-setstate-being-called-twice-in-a-function-called-once-why that references this facebook/react#12856 (comment) It seems is that is the current behaviour of React, executing twice the setter callback when using React.StrictMode. So my question is: Is it possible that React strictMode is being activated on production release? Maybe a solution could be execute the code inside setEditingRowDataState at outside the setter, obtaining the prev by checking the component data reference and simply just return the newRowData. I don't know. |
RP submitted
|
Describe the bug
onCellEditComplete
of theColumn
component in theDataTable
is fired twice on version 10.5.1Can be reproduced with the StackBlitz example directly from the docs.
This was working fine on version 9.6.4
Reproducer
https://stackblitz.com/edit/rb6yv7?file=src%2FApp.tsx
PrimeReact version
10.5.1
React version
18.x
Language
TypeScript
Build / Runtime
Vite
Browser(s)
No response
Steps to reproduce the behavior
Edit cell, click away and see that the
onCellEditComplete
is called twice.Expected behavior
onCellEditComplete
should be called only onceThe text was updated successfully, but these errors were encountered: