I’ve developed a custom “ticket_top_navigation” placeholder app that displays a dialog using showDialog(). It works fine in the development environment. However after publication to production the dialog fails to open. At one point it ran successfully in chrome but not firefox. Currently the dialog fails to launch in either browser. The only error in the console is the following:
TypeError: Cannot read properties of null (reading 'parentNode')
at HTMLElement.handleUnpreparedAnnotatable (freshconnect-sidebar-core.js:4093:73)
at HTMLDocument.i (vendor-8cbb381197009…5c1eae1.js:17111:52)
However that error also appears in the console when running under the development environment.
Note others have reported similar problems but no solution is provided:
For those experiencing this problem, the template code generated by the FDK creates buggy code. The problem is due to the use of ‘async’ in the scripts tag and the omission of the script that defines the app client. Here is the index.html that resolves the problem:
Note also that I removed ‘async’ and used ‘defer’. ‘defer’ preserves script order whereas ‘async’ does not. The following post was a hint as well as a github example.
I also followed the github example and omitted ‘async’ and ‘defer’ from the script tags in the modal view.
Now when I click the “ticket_top_navigation” button the modal dialog opens without fail (albeit with expected delays due to requests required for populating fields in the dialog).
Actually, we have replaced the fresh_client.js file with the dynamic script file with this line:
<script defer src="{{{appclient}}}"></script>
It will automatically load the latest version of the script for enhanced features of the platform rather than sticking to a particular version.
So, you don’t have to load the “https://static.freshdev.io/fdk/2.0/assets/fresh_client.js” script.
The issue is mainly caused by the order of the scripts placed in the HTML file and the usage of the async and defer keywords. The appclient script should load before your app.js script is loaded. If that fails, the app will not initialize or misbehave, saying the app is not available.
If you can achieve this, whatever way works fine. You can also refer to this sample app for the appropriate way to load both scripts.
I’ve confirmed that removing <script defer src="https://static.freshdev.io/fdk/2.0/assets/fresh_client.js"></script> the app functions as intended. Odd. In my testing I was getting client not defined errors in the console without <script defer src="https://static.freshdev.io/fdk/2.0/assets/fresh_client.js"></script> with the same script ordering and defer that I showed in index.html.