Bug with Datasources count in Experience Editor

Posted by

Recently, in one of the environments we were building up, we noticed some issues with errors in the console pointing to either ShowDatasources.js throwing a null exception or DataSources Count being stuck in a loop in the Experience Editor.

This was also having a impact on the Experience Editor performance Content Users were experiencing.

After some research i found the cause. This are my notes and fix for this issue:

Versions affected: 9.0.X, 9.1.X
Filename: ShowDataSources.js
Filepath: ​…\sitecore\shell\client\Sitecore\ExperienceEditor\Commands\ShowDataSources.js
Description:
Find “showPublishAffectedPagesNotification” method (should be around 1000th line)
You should see something like this:
this.command.context.app.showNotification(“notification”, notificationTitle, true);
Change this line to: 
this.commandContext.app.showNotification(“notification”, notificationTitle, true);

Go to sitecore/shell/Application/Page Modes/Ouput and you should see files like 1781124564654654.js. 
Delete all of them and restart the application. On restart sitecore will merge the JS files and create
new cached JS files with new fix.