onChange is triggering multiple times
Hi @bartaxyz, nice work! 👍 I was looking for something like this.
The onChange event is triggering multiple times. Maybe there should be an (additional) event onDataChange or onOrderChange.
Cheers! :)
Hi, thank you for the issue report!
I just created a quick PR to address part of this issue (multiple triggers of onChange): https://github.com/bartaxyz/react-tree-list/pull/16
I do have plans to include more types of events in the future. So far this component is fairly simple. Would you have feedback about how onDataChange could look/behave when it's implemented?
I like the simplicity of you component a lot! Thanks for the update!
It looks like the onChange event is triggering twice. The first trigger is on start dragging and the second is on releasing the node.
For example you wanna write the order to an database, the event would cause an two operations for the database update.
I was thinking about a while, how the event should work.
Your onChange event behaves more like an onComponentUpdate. In my opinion the onChange should behave like the logic, that was in my mind for the onDataChange.
onChange should be only triggered once after the tree data was changed.
- on releasing a node on a different location and the order was changed
- on programmatically changing the order, adding or removing items
I guess this is the expected event logic like in the input fields.