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

Incorrect / stale context.listView on updated SharePoint List UI experience (ListView Command Set)

Open chrisredman01 opened this issue 1 year ago • 6 comments

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

  • [ ] 💥 Internet Explorer
  • [ ] 💥 Microsoft Edge
  • [X] 💥 Google Chrome
  • [ ] 💥 FireFox
  • [ ] 💥 Safari
  • [ ] mobile (iOS/iPadOS)
  • [ ] mobile (Android)
  • [ ] not applicable
  • [ ] other (enter in the "Additional environment details" area below)

Additional environment details

  • browser version 128.0.6613.114
  • SPFx version 1.19.0
  • Node.js version v18.20.4

Describe the bug / error

When a SharePoint List is using the updated UI experience, and the list has folders enabled, the this.context.listView object is not kept in sync.

For example, this.context.listView.folderInfo.folderPath property contains the initial value when the page is loaded, but is not updated when the user clicks in to folders on the list.

The this.context.listView.rows is also stale, and only shows the items from the initial page load.

We have a ListView Command Set extension which uses the folderPath property to determine where in the list the user is when they clicked the Command Set button.

This differs to the behaviour on the 'old' modern UI.

Example:

  • First load of the list is mainly correct i.e. empty folder path as it's the root, rows = 3 image

  • Clicking in to 'Test' folder, folder path is still empty, and we see row count of 3, rather than row count of 1 image

  • If the page is refreshed while in the 'Test' folder, the context is correct image

  • Clicking 'My List' on the breadcrumb, then leaves the context stale and showing the values for the 'Test' folder still image

Steps to reproduce

  1. Create the default Command Set SPFx extension and update the config so it applies to Lists
  2. Change the dialog to output this.content.listView.folderInfo.folderPath and add console.log(this.context.listView)
  3. Create a SharePoint List and enable the 'New Folder' option via Advanced Settings
  4. Add items and a folder to the list
  5. Deploy the SPFx package
  6. Click in to the folder, then click the Command Set button
  7. Observe the stale context in the console
  8. Refresh the page while in the folder and click the Command Set button
  9. Observe the context is correct
  10. Click back to the root of the list using the list breadcrumb, and click the Command Set button
  11. Observe the context is stale

Expected behavior

The listView object should reflect the correct rows property and folderInfo, as it does on the 'old' modern experience.

chrisredman01 avatar Sep 05 '24 13:09 chrisredman01

@reedpamsft thanks for your responses in #9944.

I've attached a basic SPFx package that was to demonstrate the broken behaviour for this issue.

If you did get chance to test this with the updated UI, that would be really helpful - thanks!

spfx-test-app.zip - the zip contains the deployable sppkg and a zip of the source code.

If you configure a SharePoint List to support folders and add a few items. There will be a 'Folder Info' button on the command bar. Clicking this will open a dialog and write details to the console to check the listView context matches up.

So if you do this at root level, then within a folder, hopefully the console messages match with what the SharePoint view is showing.

Folder1

Folder2

chrisredman01 avatar Oct 03 '24 08:10 chrisredman01

@chrisredman01 thanks for sharing! I am seeing the alert and console logging working.

image

reedpamsft avatar Oct 03 '24 16:10 reedpamsft

@reedpamsft Ok great - and if you click into that 'Folder1', does it correctly reflect the files in the folder when you click the command bar button again? Thanks for taking time to test.

chrisredman01 avatar Oct 03 '24 16:10 chrisredman01

@chrisredman01 seems to!

image

reedpamsft avatar Oct 03 '24 17:10 reedpamsft

@reedpamsft - the UI changes have now hit my tenancy, but I'm not seeing the expected behaviour?

  • From root of List, clicking into Folder
  • Click the 'Folder Info' command set button
  • Context is showing the root info

image

If you refresh the page while in the folder:

  • Click 'Folder Info' now shows correct info
  • Clicking back to the root of the folder
  • Then 'Folder Info' now shows the info from the Folder still

image

chrisredman01 avatar Oct 08 '24 12:10 chrisredman01

@chrisredman01 thanks! I think this matches with other behavior we've seen reported. We have a bug fix that should be coming soon (essentially the next client build that releases). We'll leave the changes set to first release users until that fix is available worldwide.

reedpamsft avatar Oct 08 '24 18:10 reedpamsft

Hello @chrisredman01 , Thank you for your patience. Is the issue resolved now?

Amey-MSFT avatar Apr 08 '25 06:04 Amey-MSFT

We are closing this issue for now. If the problem persists, feel free to reopen it or open a new one.

Amey-MSFT avatar Jul 07 '25 10:07 Amey-MSFT