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

Inconsistent File Viewing/Rendering via auto-library reload (RenderListDataAsStream)

Open chrisredman01 opened this issue 1 year ago • 0 comments

Target SharePoint environment

SharePoint Online

What SharePoint development model, framework, SDK or API is this about?

other (enter in the "Additional environment details" area below)

Developer environment

None

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 Chrome 128.0.6613.138
  • SharePoint Modern Experience

Describe the bug / error

We are using the Graph API / CSOM to effectively replace an existing file with a stub/link file.

This uses the following Graph API endpoints:

  • Renames "Filename.docx" to "Filename.docx.url" PATCH /drives/{drive-id}/items/{item-id} (docs)

  • Replaces the file content with the URL Shortcut contents PUT /drives/{drive-id}/items/{item-id}/content (docs)

  • Deletes all previous version history via CSOM ListItem.Versions.DeleteAll()

We observe that the Document Library does a reload of the contents and shows the updated file.

However, clicking to view the file behaves differently until the full browser page is refreshed.

For example, the URL file is treated as a file download by the browser. After a page refresh, clicking the URL file will correctly navigate to the URL within the file (desired behaviour).

Url

The same can be seen for a 'txt' file. It is passed off to be rendered by the browser (e.g. displayed in a new tab). After a page refresh, clicking the 'txt' file results in it opening within the SharePoint Text viewer/editor.

Txt

Steps to reproduce

  1. Add an Office document to a library
  2. Call the Graph API to rename the file to a different format i.e. {Filename}.url
  3. Call the Graph API to replace the file contents i.e. the .url content
  4. Wait for the Document Library to reload automatically
  5. Click the file and observe the rendering is handled by the browser
  6. Refresh the page and click the file
  7. Observe the rendering is handled by SharePoint (desired) e.g. the URL shortcut is followed, or the txt file opens within the editor dialog.

Expected behavior

Ideally the behaviour would be consistent, and handled by SharePoint rendering.

chrisredman01 avatar Sep 20 '24 15:09 chrisredman01