sp-dev-docs icon indicating copy to clipboard operation
sp-dev-docs copied to clipboard

SPComponentLoader error in SPFx application extension when opening a file in document library

Open ystetsyuk opened this issue 5 years ago • 5 comments

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

  1. Create SPFx application customizer, put the code provided above into it, and deploy it to the SharePoint site.
  2. Upload any *.txt file to the Document library
  3. 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
  4. Copy and paste this URL in the new browser tab
  5. The file will be opened in a browser but the error mentioned above will be displayed.
  6. 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

ystetsyuk avatar Apr 15 '21 11:04 ystetsyuk

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

ghost avatar Apr 15 '21 11:04 ghost

Hi @ystetsyuk, Sorry for the long delay. Seems like the issue is fixed by now.

Could you please check it on your end?

Thanks!

AJIXuMuK avatar Oct 01 '21 21:10 AJIXuMuK

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

ystetsyuk avatar Oct 04 '21 08:10 ystetsyuk

Thank you @ystetsyuk for the confirmation!

AJIXuMuK avatar Oct 04 '21 12:10 AJIXuMuK

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

ghost avatar Oct 11 '21 18:10 ghost