sharepoint online - SPFx Extension Listviewcommandset fails to add COMMANDs and fire onInit() - Stack Overflow

admin2025-04-16  3

For the last 3 weeks I have been trying to resolve an issue with my SPFx Extension with ListViewCommandSet. It will not add the Commands to the command bar and it will not fire the "onInit()" function of the extension to get things started.

Feeling defeated, I tried a few additional approaches, that was to use pure Yeoman Generator output not knowing what it looked like when it worked, I didn't have much luck.

Fortunately, I found a sample of a ListViewCommandSet on the SharePoint/sp-dev-training-spfx-extensions site. I built that code and had the same exact problem, it will not load the commands to the commandbar and it will not fire the onInit() function to get things started.

After a deeper dive, I have seen similar statements but more around webparts where the included command bar would be empty:

Digging deeper and reviewing some other peoples experiences it seems like the commandbar in the Extension will work under very non-user friendly conditions which will not work as a product, you need to directly link to the page (some rumor you have to use classical list view), if you go off of that page to another page and return you have the same issues again.

The best way to test this is to:

  • build the 03-listviewcommandset
  • configure serve.json to point to a single library page with 3 or more documents in it
  • use "gulp serve" to start the process
  • After loading you will need to do a ctrl-F5 to flush the buffer and wake up the system at times
  • You should be able to see the buttons in the commandbar based upon the demo logic
  • navagate away to the "Site contents" or something and then return and you will see that the buttons no longer appear on the commandbar

This is using SPFx V1.20, there are no errors or anything reported to the console upon failure, just a silent failure of the Extension.

Useful links:

.pptx

Has anyone figure out how to get this to work consistantly? Is there another tool or approach I should be using rather than SPFx or a different Gulp loader or something? The DEMOs are not working so I think I am pretty sure I am setup correctly to compiler and deploy those with the same faulty results.

转载请注明原文地址:http://anycun.com/QandA/1744790232a87661.html