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

SPFx list command sets | Update refresh list content

Open Tanddant opened this issue 2 years ago • 2 comments

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 🙌

Tanddant avatar Nov 22 '23 12:11 Tanddant

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

ghost avatar Nov 22 '23 12:11 ghost

Hi, do you have any update on this one?

matteomessmer avatar Jun 28 '24 08:06 matteomessmer

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.

Feets20 avatar Jan 15 '25 21:01 Feets20

Thanks for the mention! I wasn't aware of this...

How are you updating the items? Directly calling APIs? Using a particular js library?

reedpamsft avatar Jan 15 '25 22:01 reedpamsft

Usually either Graph or the SharePoint REST API (PnPjs 9 times out of 10)

Tanddant avatar Jan 15 '25 23:01 Tanddant

Our items are generally updated through CSOM, and we have our SPFx call C# APIs to to the data updates

Feets20 avatar Jan 16 '25 16:01 Feets20

Any updates on this issue?

Alexander

SPJS avatar Jan 28 '25 15:01 SPJS

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 avatar Jan 28 '25 16:01 reedpamsft

@reedpamsft Thanks for the update. I hope this can be resolved as soon as possible.

Alexander

SPJS avatar Jan 29 '25 11:01 SPJS

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 avatar Jan 29 '25 16:01 reedpamsft

@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 avatar Jan 29 '25 19:01 SPJS

@SPJS yeah, that's where my head is at too, but even that's not a quick fix.

reedpamsft avatar Jan 29 '25 19:01 reedpamsft

@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.

Image

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!

Ashlesha-MSFT avatar Jul 18 '25 10:07 Ashlesha-MSFT

@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 avatar Sep 12 '25 09:09 jansenbe

@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?

Tanddant avatar Sep 12 '25 13:09 Tanddant