We are experiencing issues with the redo-undo functionality. When the project loads, the undo count is set to 1, even though no changes have been made.
Additionally, after making several changes, the redo functionality shows the correct number of changes. However, after redoing all changes, it still indicates 1 change remaining.
Attached are a runnable test and a video demonstrating the issue.
This happened because you update startDate of the projectModel after load. You subscribed on load that set data to dateField. That change initiates onStartDateChange call that change projectModel's startDate. I updated the code with this:
We have tried both options, but neither seems to resolve the issue. The first option results in no changes being tracked at all, while the second does not fix the issue we raised. Could you please provide further guidance?
Sorry for confusing, that's my mistake. After double-check I found that I tested in not valid code state with commented refresh handler. I've spent more time on it, but was not able to fix this right away. I opened a ticket to fix this https://github.com/bryntum/support/issues/9559
You can subscribe on ticket updates to be notified when it's done.
When the project loads, the undo count is set to 1, even though no changes have been made.
To avoid this, one should enable the stm mechanism only after the initial data loading is fully complete. Otherwise, if stm is enabled, but data is still being loaded/mutated - that will be picked up as a undo/redo transaction. This is what happens in this case.
Unfortunately, there's some issue in the loadCrudManagerData method and it requires an additional await project.commitAsync() call after, to process the data. Stm should be enabled only after that call.
A workaround looks like this:
remove this.gantt.project.stm.enable(); call from updateStartDateField
change initGantt in src/app/components/gantt.component.tsx to:
const initGantt = async () => {
await ganttRef.current.instance.crudManager.loadCrudManagerData(ganttData);
const ganttInstance = ganttRef.current.instance;
await ganttInstance.project.commitAsync()
if (ganttInstance.isDestroyed) return;
ganttInstance.eventStore.syncDataOnLoad = false;
ganttInstance.project.stm.resetQueue();
// enable stm and start recording changes only after all initial data loading/processing is completed
ganttInstance.project.stm.enable();
ganttInstance.taskStore.wbsMode = "auto";
};
It seems gantt chart is actually re-created during data loading, thus the ganttInstance.isDestroyed check - but this is something related to react effects system and you'll need to debug it yourself.
After fixing the initial issue, it seems the 2nd issue you mention is not reproducible, please verify.
I'll also investigate why loadCrudManagerData method requires an extra commitAsync() call after, so hopefully this will be fixed in the next release.
we tried your solution and it works good for the first project we upload - for the first ganttData.
But this issue appear again if we replace/change it with another data(ganttData is changed).
The initial stm.disable() call will disable stm and stop any ongoing transaction. Then, after data loading the queue will be reset and stm will be re-enabled.