Open a wiki page with context action view (normal mode)
Open any other viewer (information, comments, history)
See warning Annotations could not be loaded because the content is not available.
The warning is coming from initialize function of the Annotation class in the script loaded from /bin/jsx/AnnotationCode/Script.
It is thrown when the class property annotatedElement is not defined. As you can see in the bottom of the file, the Annotation script is initialized with element $('#xwikicontent')[0].
There is a check earlier on:
if (XWiki.contextaction != 'view' || !$('xwikicontent')) {
return;
}
The return value of $('xwikicontent') is an object of zero or multiple elements by tag “xwikicontent” and therefore never undefined so the AnnotationCode does not notice that it should stop to run.
=> $('#xwikicontent')[0] should be used
It seems the issue could not be reproduced on my side on XWiki 18.1.0 and XWiki 17.10.3 (tested on Jetty/HSQL distribution, Chrome 145, @atarata tested as well). The reproduction steps we performed:
Go to Administer Wiki > Content > Annotations
Tick “Display annotations by default” and Save
Go to a page that has some text content (Main Page, Sandbox or a page created by the user) in View Mode
Clicked on Comments, Attachments, History and Information Tabs
Tried also to add some annotations to the text before clicking on the tabs (between Steps 3 and 4), performed some page refreshes / cleared cache.
However, the message Annotations could not be loaded because the content is not available. was encountered indeed, but in the case where a page that is accessed was deleted (see the reported issue: XWIKI-24071).
If there is other (additional info) that leads to reproducing the issue, please add comments on XWIKI-24071.
Hey, I just confirmed the bug on XWiki Docker 18.1.0 and 17.10.3 (Tomcat/PostgreSQL distribution, Firefox 148).
Please make sure to manually clear the cache after saving settings.
Go to Administer Wiki > Content > Annotations
Tick “Display annotations by default” to enable
Save settings
Clear cache for the new setting to apply (the annotation code is cached poorly - in Firefox the cache can be cleared using the shortcut Ctrl+Shift+R)
Go to Sandbox page in view mode
Open the dropdown menu in the top right of the wiki page header
Open information viewer
Can you reproduce this?
The encountered message will display on any page that is opened in view mode but has no #xwikicontent container (includes deleted pages, information viewer, comments viewer and more).