SPComponentLoader error in SPFx application extension when opening a file in document library
Category
- [x] Bug
Describe the bug
I am using SPComponentLoader to load SP.js in SPFx application customizer:
SPComponentLoader.loadScript('/_layouts/15/init.js', {
globalExportsName: '$_global_init'
}).then( () =>{ console.log("init.js loaded"); } )
The code above works on almost all SharePoint forms & pages except this one page: https://{tenant}.sharepoint.com/site1/Docs/Forms/AllItems.aspx?id=%2Fsite1%2FDocs%2FSubfolder1%2Fsomefile%2Etxt&parent=%2Fsite1%2FDocs%2FSubfolder1
The following error is displayed in the browser console: "Uncaught (in promise) Error: No define call for /_layouts/15/init.js http://requirejs.org/docs/errors.html#nodefine".
Steps to reproduce
- Create SPFx application customizer, put the code provided above into it, and deploy it to the SharePoint site.
- Upload any *.txt file to the Document library
- Click on this file. A browser window will redirect silently to a URL like this: https://{tenant}.sharepoint.com/site1/Docs/Forms/AllItems.aspx?id=%2Fsite1%2FDocs%2FSubfolder1%2Fsomefile%2Etxt&parent=%2Fsite1%2FDocs%2FSubfolder1
- Copy and paste this URL in the new browser tab
- The file will be opened in a browser but the error mentioned above will be displayed.
- Even if you navigate to another list using left navigation (silent navigation will occur without reloading the whole browser window), then SPComponentLoader cannot be used there as well. The same error will be displayed.
Expected behavior
The error should not happen. There are similar closed issues: #1180 and #2505, but the fixes do still not work for the mentioned above page.
Environment details (development & target environment)
I use SharePoint mod environment
Best regards, Yuriy
Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.
Hi @ystetsyuk, Sorry for the long delay. Seems like the issue is fixed by now.
Could you please check it on your end?
Thanks!
Hi @AJIXuMuK ,
I am not able to reproduce the issue now, seems it has been fixed. Now SP.js is loaded for this page as well.
Thanks, Yuriy
Thank you @ystetsyuk for the confirmation!
Issues that have been closed & had no follow-up activity for at least 7 days are automatically locked. Please refer to our wiki for more details, including how to remediate this action if you feel this was done prematurely or in error: Issue List: Our approach to locked issues