I'm using AEM Forms and I use a lot of fragments. Sometimes the fragments have some code, for example the company header that can change depending on the brand code. One thing I noticed is that when you use those fragments on a form, if you click on that fragment, the code appears to not be editable (grayed-out), and if you try to type something it won't allow you, but, if you press some keys like tab or enter or space bar, the code will start to be editable. And you might even not edit anything (maybe you just added an enter accidentally), but the entire fragment code will now be in the form's XML source code. And once this code is in the form's xml code, the fragment kinda loses it's point (in the form that you accidentally "edited"), because from now on, any code that you add to your fragment will be ignored, because the program will actually use the code that is in the forms xml source. So my question is if there would be any way to protect myself from this?
Here is an example. The fragment has some code and it's locked initially and nothing on the xml source of the form:
(it even shows this message that I highlighted)
Now if I, for example, accidentally click on the tab button. In this picture I already pressed tab, and the editor window still appears to be grayed-out:
But on the xml source file, it added all the fragment code:
The only ways I found to fix this, is either delete the code from the xml file or to remove the fragment and add it again. Any suggestions?
Also a note: If the fragment code is in the root of the fragment, the code in the form it won't even be grayed-out, so it is even easier to accidentally edit the code. If you edit it, it does the same thing (adds the code to the xml source).