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

SPFx ListViewCommandSet Extensions are no longer being loaded when switching list context in side navigation!

Open frevds opened this issue 6 years ago • 67 comments

Category

  • [x] Bug

Describe the bug

Okay, let't try that again in the right section.

I registered a ListViewCommandSet Extension for a list. But the extension is not being loaded, if I don't directly navigate to that list:

If I open the list page for a list for which the extension is activated, the extension gets loaded (constructor called, onInit called).

If I open the list page for another list for which the extension is not activated and then navigate to the list for which it is activated, using the navigation tree, the extension does NOT get loaded.

Also, if the extension was loaded for a list and the user switches to another list using the navigation, any extension activated for that list does not get initialized (constructor or onInit is not being called again).

Finally, the onListViewUpdated-Event never worked.

This issue makes list view command set extensions quite useless and breaks our product. Is there any fix coming for this or should we move on to generic extensions loaded for every page?

Steps to reproduce

Use the yo generator to create a new ListViewCommandSet and try on your own to get it loaded for a list if you don't directly navigate to it (in SharePoint Online), see details above.

Second problem: the onListViewUpdated-Event never fires, no matter what you do in the ListView (provided the extension was loaded at all).

Expected behavior

Extensions should be loaded for lists on which they are registered, when you navigate to the list (using the navigation). Currently they are only loaded if you directly enter the correct list when opening the browser page, not when navigating in the tree (where the page does not reload but merely React controls get rerendered). This behaviour did work before, but is now broken.

Second problem: Changes in the selection of the list view should fire the event. Maybe even changes to the list context (navigating).

Environment details (development & target environment)

  • OS: Windows 10
  • Target Environment: SharePoint Online
  • Framework: Node.js v10
  • Browser(s): Chromium Edge latest
  • Tooling: SPFx v1.10.0
  • Additional details: Suspecting latest changes in SPO, client and solution did not change

Additional context

frevds avatar May 09 '20 18:05 frevds

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

msft-github-bot avatar May 09 '20 18:05 msft-github-bot

Can confirm the problem in our SPFx v1.10.0 CommandSet Extension as well. The CommandSet is only loaded correctly if directly accessed. If we use left navigation, the extension is not initialized an onListViewUpdated is never fired. If we reload the page with F5 or STRG+F5 the extension on the same list is loaded and works till we navigate to another list in the left navigation.

chr-sad avatar May 11 '20 09:05 chr-sad

I would also like to point out that we are experiencing the exact same issue, but filtering the view even when navigating directly to the list/library causes the command set extension to bug out and stop working.

RowanAdvisors avatar May 13 '20 20:05 RowanAdvisors

@RowanAdvisors I just tried to reproduce the filtering issue but I can not confirm a problem here. At least in our solution on our tenant even when filtering is active, the CommandSet Extension works correctly for our use case.

chr-sad avatar May 15 '20 06:05 chr-sad

Yes same for me, filtering does not do anything bad to our extension, but then our extension does not add any toolbar buttons. What does "bug out and stop working" mean in your case @RowanAdvisors?

frevds avatar May 15 '20 08:05 frevds

I am facing the same issue:When the document library is opened for the first time from quick launch menu(left navigation menu) it loads the Command bar spfx extensions But when we switch to another library from quick launch it does not refresh the whole page and as a result
this time the command bar spfx extension does not load.It only loads after we refresh the entire page/press F5

Debopoma-netwoven avatar May 27 '20 10:05 Debopoma-netwoven

Same here. Command only appears on the first list. When navigating to another list over the left navigation the command bar is not shown anymore.

barisbikmaz avatar May 27 '20 20:05 barisbikmaz

I just upgraded to SPFx v1.10.0 and can confirm this behaviour. When navigating to another list using the quick launh, the commandbar does not refresh nor is there any hit on onInit of the BaseListViewCommandSet. Currently this is blocking our corporate deployment.

HansSissing avatar Jun 11 '20 11:06 HansSissing

@69mustang302 Are you implying that this is not a SharePoint issue but a SPFx framework issue, i.e. does this all still work with SPFX < 1.10?

frevds avatar Jun 11 '20 13:06 frevds

@frevds Just checked on another tenant that still has the 1.9.1 version running of my solution, and no, it's a SharePoint issue, same behaviour there! And another non-related issue : https://github.com/SharePoint/sp-dev-docs/issues/5681 But also caused by changes on SharePoint.

HansSissing avatar Jun 11 '20 13:06 HansSissing

@69mustang302 Yes, that's how it should be. So far so good. It seems when they changed their React app recently, they "forgot" about the extensions. It should be a simple matter, but of course will take forever before we see any new release. But I expect this issue will get solved eventually, since extensibility of SharePoint using SPFx is kind of important enough. And if not, well, then I guess we'll have to switch to ApplicationCustomizers being loaded on every modern page.

frevds avatar Jun 11 '20 14:06 frevds

Let's hope for a quickupdate, and well, i guess you could (ab)use ApplicationCustomizers in that way ;) Lets keep an eye out for the version update of spo, you can find your version here:

HansSissing avatar Jun 11 '20 14:06 HansSissing

If I'm not mistaken I think the extensions do load again after navigating in the tree. Can somebody confirm that? Seeing odsp-next-prod-webpack_2020-06-05-sts_20200611.001 here.

frevds avatar Jun 18 '20 17:06 frevds

On my tenant I have the same version update to 2020-06-05. Something has changed, however the onInit() now only excecutes twice The scenario is as follows:

  1. I open the list targettted by the extension by browsing to the url (refresh) : onInit() executes.
  2. I navigate using the quick launch to a list that is not targetted by the extension: onInit() excecutes - that's what we want!
  3. I navigate to the targetted list using the quick launch : onInit() does NOT excecute.
  4. Repeated navigations, changing lists does not trigger onInit()

Only refreshing the page with [F5] allows you to repeat the above scenario. So unfortunately, it is not yet the fix we hoped for...

I want to point out that also this (related) issue is still not solved with this version : this.context.listView.columns is an empty array #5681

HansSissing avatar Jun 19 '20 12:06 HansSissing

@69mustang302 I can confirm that onInit is only called ONCE per targeted list, but i can NOT confirm that onInit is called for non-targeted lists. So if I navigate to a list that is targeted, the extension gets initialized, when I navigate to another targeted list, the extension gets initialized (now with the latest update; this was the original issue). When I then navigate back (using the left-side tree or the browser Back button) to the earlier targeted list, the onInit is not called again (I don't do integrations such as buttons, only page context manipulations, so this is fine for me, but I don't know whether regular interactions with the list view require repeated onInit calls). And if I navigate to any non-targeted list, nothing happens (which is how it should be).

frevds avatar Jun 19 '20 12:06 frevds

@frevds A ListView CommandSet should fire on every list visit. In a listview commandset extension, in onInit() you can then decide to show or hide buttons in the commandbar depending on the context of the list provided through this.context . What I call a " targetted" list is a list which meets my functional requirements and should show my custom buttons and react to item selection depending on your functional requirement. In this video i demonstrate the effect: ListViewCommandSetDemoVideo. As you can see, the custom buttons appear when visiting the list, however after navigating slolely using the quick launch. The custom buttons do no get rendered again. So imho it's not fixed....

HansSissing avatar Jun 19 '20 14:06 HansSissing

@69mustang302 Ah yes, indeed, that's not solved then, if the UI extensions cannot be reestablished. Good that we clarified the term "targeted". I refered to lists for which the SharePoint-Custom-Action was deployed (I do this via list.UserCustomActions.Add). Well, I reckon, since there was no response here yet from people involved, that they're still in the middle of it. But good to see some progress. It does suffice for me (as I'm merely using onInit to hack into the ActionMap, which needs to be done only once), but I'll leave the ticket open until this is working completely.

frevds avatar Jun 19 '20 14:06 frevds

PS: @69mustang302 The other ticket about this mentions some workaround (where you can force a reload of the whole page when navigating): https://github.com/SharePoint/sp-dev-docs/issues/5776#issuecomment-640717900

frevds avatar Jun 19 '20 15:06 frevds

@frevds Thanks for leaving this open, and yes, clarity is key ;) In my scenario, the extension is bound to multiple lists, and is activated depending on the list’s properties, rather than being bound to one list. So we’ll keep monitoring this issue. Thanks for the link to the possible workaround, however we have deployed some 2000+ site collections, hence it is not feasible to instruct users to update their quicklaunch without being buried in support cases...

HansSissing avatar Jun 19 '20 15:06 HansSissing

@69mustang302 Another possible workaround in your case: Since the page URL (location.href) changes during navigation in the tree, you could have a background task (Javascript's setInterval) running to check every 200msec whether the URL is still the same (or similar mechanism to detect changes). If it did change, do a location.reload() to reload the whole page and have your extension activate again. Not pretty but should patch the issue until the time comes when SharePoint fixes it (for a graceful transition store the expected URL in a global variable so all instances of your extension access the same URL (and the URL should only be the location.pathname), then when they fix it, your new extension will set this variable when being activated before the old extension's timer recognizes a change). The timer itself should also be singleton, i.e. stored in a global varialbe and only started if not yet running.

frevds avatar Jun 19 '20 15:06 frevds