I noticed some behaviour with XPM that is a bit weird. Here is an example where using an onclick-event for printing a page.
<button onclick="window.print();" @Html.DxaPropertyMarkup(() => Model.PrintButtonLabel)> @Model.PrintButtonLabel </button>
When clicking on the link, or pressing space the onclick-event is triggered. If I am rendering links inside a DxaPropertyMarkup box, it will navigate to that link if I happen to click on the area containing the link. An editor probably don't want to actually execute the actions, they wanna edit the content.
I've been trying to figure out a couple of solutions for this:
Detecting wheter or not we are in XPM-edit mode and not rendering the onclick-event. I have been unable to find any code example that is related to this.
Blocking all href+onclick inside a DxaPropertyMarkup. I don't want an editor to navigate through the site or calling on events when they are editing a page.
Is there a way to do any of the above solutions or do you have something better in mind?