BoldSign®Effortlessly integrate e-signatures into your app with the BoldSign® API. Create a sandbox account!
Hi
I've recently been added Undo/Redo functionality to my application.
I noticed that sometimes the diagram will log an event when I click on a node even though nothing has changed. The problem is that my Undo button becomes active but there is actually nothing to Undo.
I can demonstrate the issue in this stackblitz:
https://stackblitz.com/edit/stackblitz-starters-jtt4vr?file=src%2Fapp%2Fdiag%2Fdiag.component.ts
I have also recorded the attached video. In the video you can see that I simply click on a node and every once in a while an event gets added to the history.
Hi,
Upon analyzing the video you shared, we found that a history entry is added while the position changes. We suspect that the node moves slightly during selection or deselection, it will be added to the history, triggering the event.
Regards
Vivisa
At first that was my thought too. But I don't think so for 2 reasons:
Hi,
We will validate and update you with more details on August 6,2024.
Regards,
Vivisa
Hi,
We still cannot reproduce the issue from our end as it occurs on random event. we will further validate and update you with more details on August 8,2024.
Regards,
Moulidharan
Hi,
The reported scenario occurs randomly due to the framework's mousemove event, which triggers the diagram's positionChange event. Since this behavior is caused by the framework, setting args.cancel to true in our positionChange events does not resolve the issue. Consequently, it is not feasible to handle this directly within the diagram source. You will need to explore options to prevent the framework's mousemove event from interfering. Unfortunately, we do not have any other solutions available on our end.
Regards,
Vivisa
I've learned about the canLog function (https://ej2.syncfusion.com/angular/documentation/diagram/undo-redo#canlog ) which can be used to cancel additions to the history. I've implement it here:
I feel like there must be a way to set historyEntry.cancel to true if the position change isn't 'real'.
Can this be used?
Hi,
Yes, you can restrict a history entry from being added when the positionChange event is triggered by using the canLog property. We have modified the sample according to your requirements. Refer to the sample and code snippet below:
Code-snippet:
public created(): void { this.diagram.fitToPage();
this.diagram.historyManager.canLog = (historyEntry: HistoryEntry) => { console.log(historyEntry); if (historyEntry.type == 'PositionChanged') { historyEntry.cancel = true; } return historyEntry; }; }
|
Sample:
https://stackblitz.com/edit/stackblitz-starters-zkhphg?file=src%2Fapp%2Fdiag%2Fdiag.component.ts
Regards,
Vivisa
Hi -
I tried your stackblitz and it doesn't work for 2 reasons:
Hi,
We will validate and update you with more details on August 19,2024.
Regards,
Vivisa
I've noticed the same issue with Undo/Redo functionality where events are logged even without changes, activating the Undo button unnecessarily. It might help to add a condition that checks for actual changes before logging events, preventing the history manager from recording irrelevant actions.
Thanks for sharing the demo and video!
Hi Surah I agree - I am thinking the same thing but don't have enough knowledge of the inner workings of the events to figure this out so I'll see what they come back with on Aug 19, 2024.
Hi,
Reported Issue: Clear empty history entries in the history manager while cancelling entry using canLog.
We can reproduce the issue and confirmed this as a defect. We have logged a defect report for this issue. We will fix this issue and provide the patch on 10th September,2024 weekly patch release.
Feedback Link: https://www.syncfusion.com/feedback/60552/clear-empty-history-entries-in-the-history-manager-while-cancelling-entry-using
Disclaimer: Inclusion of this solution in the weekly release may change due to other factors including but not limited to QA checks and works reprioritization.
Regards,
Moulidharan
Hi,
We have fixed the issue and provided custom package below. However, we will include the fix for the issue in our upcoming volume 3 release which is scheduled to release on next week.
Regards,
Vivisa
Hi,
We have fixed the reported issue and included it in our Essential Studio 2024
Volume 3 Main Release v27.1.48 version. Kindly
upgrade to that version to get the issue resolved.
NPM package:
https://www.npmjs.com/package/@syncfusion/ej2-diagrams
https://www.npmjs.com/package/@syncfusion/ej2-angular-diagrams
We thank you for your support and appreciate your patience in waiting for this
release. Please get in touch with us if you would require any further
assistance.
Regards,
Sarath
Hi Vivisa,
Thanks for the info. Since args.cancel
doesn't resolve the issue, I'll explore alternative solutions, like intercepting the mousemove
event or checking if the framework offers any settings to control it. I’ll keep you updated.
Hi,
Thank you for your update. Please feel free to reach out if you need further assistance, we're always happy to help!
Regards,
Dhakshin
Hi Vivisa,
Thanks for the update! I appreciate the custom package, and I look forward to the upcoming Volume 3 release next week.
Best regards,
Hi,
The reported issue is fixed in Volume 3 release and Volume 3 release is rolled out. If you are still facing any issues, please update us. Kindly provide more details on your last query.
Regards,
Dhakshin