Unable to create folders in document library after deploying SPFx Extension that loads javascript file
Target SharePoint environment
SharePoint Online
What SharePoint development model, framework, SDK or API is this about?
💥 SharePoint Framework
Developer environment
Windows
What browser(s) / client(s) have you tested
- [x] 💥 Internet Explorer
- [x] 💥 Microsoft Edge
- [x] 💥 Google Chrome
- [x] 💥 FireFox
- [x] 💥 Safari
- [ ] mobile (iOS/iPadOS)
- [ ] mobile (Android)
- [ ] not applicable
- [ ] other (enter in the "Additional environment details" area below)
Additional environment details
Describe the bug / error
We have a analytics tool that requires javascript file to be called. Created SPFx extension (App Customizer) to load the javascript file. Used SPComponentLoader.loadScript method to load a javascript file present in a site's style library.
javascript file has analytics code.
All SharePoint pages loads fine and everything is tracked in our analytics tool. I'm able to create documents in the library but i'm unable to create a folder. STRANGE!
I tested it after the deleting the solution from app catalog, it worked.
Steps to reproduce
- Create SPFx extension -> Application customizer
public onInit(): Promise<void> {
Log.info(LOG_SOURCE, `Initialized ${strings.Title}`);
const userName = this.context.pageContext.user.displayName;
(window as any).someconfig = {
userName: userName
};
SPComponentLoader.loadScript('/Style%20Library/<javascript_snippet_file>.js');
return Promise.resolve();
- Deploy the solution and select "Make this solution available to all sites....."
- Navigate to any document library
- Create a folder
Expected behavior
You will receive "Illegal invocation" error on both console and UI
Hello @dmahendranme, Thank you for bringing this issue to our attention. We will look into it and get back to you shortly.
Hello @dmahendranme, We were able to reproduce the issue, and we are investigating it. We have logged this as a bug, and our engineering team will look into it. Thank you!
@dmahendranme: We're not always able to load from style library when you use "global deployment" as the js code might not be present in each site's style library. Next to that the actually loaded JS code might result in this behavior.
As we feel this is not a product issue we're closing this one. Feel free to re-open if needed.
@jansenbe It's not about the loading JS. I see there is a misunderstanding on the issue from your response. We are hard coding the link to JS file from a site. Therefore, it works even if you deploy it globally. It does not check each site's style library as the link is hard coded. And this part works fine EVERY time. JS loads on all sites, and the analytics part works fine.
Please check with @Amey-MSFT because he/she is able to reproduce the issue. I'm unable to reopen the issue due to permission error.