SPFx list command sets | Update refresh list content
What type of issue is this?
Question
What SharePoint development model, framework, SDK or API is this about?
💥 SharePoint Framework
Target SharePoint environment
SharePoint Online
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
- Version 119.0.6045.160 (Official Build) (64-bit)
- Any (1.18.1)
- Node.js version v16.20.0
Issue description
I'm not really sure where to post this, but @VesaJuvonen linked me here during a ESPC Hot Seat Session
When building SPFx list command sets, I can update a list item via my code, but I cannot force the list to "re-render" - there used to be a hack where I could trick the DOM to "invalidate" the list contents, and force SP to update the list, but that no longer works, so my only option is to reload the entire page, creating a very 2005ish web experience ... and come on it's 2023, we should be able to build sleek web solutions.
Awesome work you're doing SPFx 🙌
Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.
Hi, do you have any update on this one?
We're running into some very similar struggles, specifically on the new List UI. @reedpamsft apologies to bug you about this, but I was curious if you had any information on if this is something on your team's radar? Genuinely just curious as we've had to come up with some pretty "hacky" solutions to try and get the list experience to update quicker when we update list items through code.
Thanks for the mention! I wasn't aware of this...
How are you updating the items? Directly calling APIs? Using a particular js library?
Usually either Graph or the SharePoint REST API (PnPjs 9 times out of 10)
Our items are generally updated through CSOM, and we have our SPFx call C# APIs to to the data updates
Any updates on this issue?
Alexander
Sorry, it's on our radar now as a thing to fix. I'm actually surprised this doesn't work, so the investigation into how to fix it might be a little complex.
@reedpamsft Thanks for the update. I hope this can be resolved as soon as possible.
Alexander
Just to set expectations: it might be a pretty major work item. The fact that it doesn't currently work suggests that this is not plugged into our normal update notification system for whatever reason.
@reedpamsft If an automatic refresh based on the list schemas LastItemUserModifiedDate property is not possible, there might be a workaround where we can trigger this refresh either from the list view command-set extension or by calling some other API?
Alexander
@SPJS yeah, that's where my head is at too, but even that's not a quick fix.
@Tanddant, In our SharePoint Framework (SPFx) ListView Command Set Extension, we implemented item duplication using @pnp/sp (REST API under the hood). After the operation, we attempted the following to trigger a list refresh without a full page reload:
- Used @pnp/sp to clone the selected list item(s).
- Invoked this.raiseOnChange() to update the command bar state.
- Attempted to call the legacy itemInvalidator.invalidateCurrentItemSet() method to force the list view to refresh.
However, the UI does not reflect newly added or updated items unless the user manually refreshes the page.
As We were able to reproduce this issue, we have logged this as a bug, and our engineering team will look into it. Thank you for your patience!
@Tanddant : auto-refresh was supported by the old list experience, however this is not a feature of the new list implementation. The list team moved this ask to their backlog, but to be transparent there's no short term plan to fix this. With that in mind I'm closing this issue, hope you can understand.
As always, thank you for providing this feedback.
@jansenbe, Thank you for taking your time to answer anyways, is there an API that we should prefer to use in order to increase our chances that the lists randomly updates?
i.e. OOTB forms use ValidateUpdateListItem() is that better? - what's the preferred approach for developers to use?