Skip to content
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

afterChange fired multiple times #3343

Closed
renathy opened this issue Mar 21, 2016 · 22 comments

Comments

@renathy
Copy link

commented Mar 21, 2016

Can you explain why afterChange event fires multiple times if I update value of once cell and lick outside it?

config.afterChange = function (changes, source) {
if (changes != null) {
console.log('htch'); // ->>> this is fired multiple times
var tableData = $container.handsontable("getData");
config.observableData(tableData);
}
};

P.S. Unofurtunately we are using old handsontable source (version 0.10 or similar).

@AMBudnik

This comment has been minimized.

Copy link
Contributor

commented Mar 21, 2016

Hi @renathy
I would ready appreciate a demo where we can check what's going on and create some conclusions.

@renathy

This comment has been minimized.

Copy link
Author

commented Mar 21, 2016

I would try to check fi afterChange event also fires multiple time on some of your examples.

@AMBudnik

This comment has been minimized.

Copy link
Contributor

commented Mar 21, 2016

@renathy ok, I'll be waiting.

@AMBudnik

This comment has been minimized.

Copy link
Contributor

commented Apr 4, 2016

Hi @renathy
How is your progress with this example?
Is there anything I can help you with?

@AMBudnik

This comment has been minimized.

Copy link
Contributor

commented Apr 21, 2016

Issue will stay closed till an authors reply.
Please take your time @renathy Issue will get reopened after you create a demo.

@AMBudnik AMBudnik closed this Apr 21, 2016

@jrowen

This comment has been minimized.

Copy link

commented Aug 31, 2016

I'm also seeing this behavior.

You can see this by going to https://jrowen.shinyapps.io/rhandsontable_output/ and watching the activity in the Javascript console while updating the table (I added some console logging; alternately you can set a breakpoint in the afterChangeCallback function in the rhandsontable source). The afterChange event appears to fire more frequently after each update.

Issue originated at jrowen/rhandsontable#98.

@AMBudnik

This comment has been minimized.

Copy link
Contributor

commented Sep 1, 2016

Hi @jrowen
can you create a simple JSFiddle demo where we'll be able to see the code?

@jrowen

This comment has been minimized.

Copy link

commented Sep 1, 2016

Unfortunately, I can't create a simple demo for this example, but with the Chrome debugger (or similar), I think you should be able to see what's going on.

The table is created through an interface between R and Javascript, and the Javascript code to create the table can be seen at https://github.com/jrowen/rhandsontable/blob/master/inst/htmlwidgets/rhandsontable.js.

I'm sorry I can't simplify debugging this (I'm open to ideas). It could be problem lies in the implementation of the interface, but the debugging I've done seems to point to the table logic. I'm wondering if it could be related to some type of data caching (maybe for undo, which doesn't seem to be working in this example).

@AMBudnik

This comment has been minimized.

Copy link
Contributor

commented Sep 1, 2016

Hi @jrowen
unfortunately now I'm getting the console error:
sockjs-0.3.min.js:27 POST https://jrowen.shinyapps.io/rhandsontable_output/__sockjs__/n=ta34DnMHHBYaw…I4/t=c2f7212a109c13c3359676ff29f7f56a/w=a2121bfc/s=0/656/ddpnah14/xhr_send net::ERR_NETWORK_CHANGED
from your example.
Without a demo code it will be very hard to replicate the bug and to fix as well.
I've created an example with similar data but the afterChange hook works as expected there. Demo: http://jsfiddle.net/k06tw3aL/

@jrowen

This comment has been minimized.

Copy link

commented Sep 1, 2016

Here's an animation that I hope helps. The console output is coming from logging in these lines and the table is created here.

pic

@AMBudnik

This comment has been minimized.

Copy link
Contributor

commented Sep 1, 2016

Do you use any additional hooks or renderers?

@jrowen

This comment has been minimized.

Copy link

commented Sep 1, 2016

The columns in the example above are using a customRenderer that handles some data type mapping between R and handsontable. The customRenderer ultimately calls the appropriate handsontable renderer.

There are a few additional hooks used to pass data back into the R (shiny) app: afterSetCellMeta, afterSelectionEnd, afterCreateRow, afterRemoveRow, afterCreateCol, afterRemoveCol.

@AMBudnik

This comment has been minimized.

Copy link
Contributor

commented Sep 2, 2016

thank you for the details @jrowen

@budnix

This comment has been minimized.

Copy link
Member

commented Oct 7, 2016

Confirmed, after investigating this issue I found that there is a problem with updateSettings. When developer passes the same listeners to the updateSettings over and over again then this listener is added to the collection of listeners instead of overwriting previous one.

Workaround for this could be to pass listeners only once while Handsontable initialization.

@masato-io

This comment has been minimized.

Copy link

commented Feb 12, 2017

I'm experiencing similar issue on react-handsontable as well. submitted issue here:
handsontable/react-handsontable#7

@AMBudnik

This comment has been minimized.

Copy link
Contributor

commented Feb 13, 2017

Hi @masato-io
React version uses the same logic so if this issue will be solved here (for community edition) it will also for from the React version (after updating it)

@masato-io

This comment has been minimized.

Copy link

commented Feb 13, 2017

Hey @AMBudnik,
Thank you for your reply. Is there any difference between community edition and paid edition in terms of this issue?

@masato-io

This comment has been minimized.

Copy link

commented Feb 14, 2017

@AMBudnik sounds good, thanks!

@AMBudnik

This comment has been minimized.

Copy link
Contributor

commented Mar 8, 2017

Hi @renathy, Can you check the updates in v0.31.1?

@masato-io

This comment has been minimized.

Copy link

commented Mar 11, 2017

for my use case, confirmed v0.31.1 is working as expected now 👍

@AMBudnik

This comment has been minimized.

Copy link
Contributor

commented Mar 13, 2017

Thank you for confirmation @masato-io
I guess we can close this issue.

@AMBudnik AMBudnik closed this Mar 13, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.