SharePoint / sp-dev-docs

SharePoint & Viva Connections Developer Documentation
https://docs.microsoft.com/en-us/sharepoint/dev/
Creative Commons Attribution 4.0 International
1.25k stars 1.01k forks source link

JSON Column link errors since SPO Fluent updates #9754

Open ian-custom365 opened 5 months ago

ian-custom365 commented 5 months ago

Target SharePoint environment

SharePoint Online

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

💥 SharePoint Framework

Developer environment

None

What browser(s) / client(s) have you tested

Additional environment details

Describe the bug / error

I see others commenting with other issues, so adding my experience here too. I have a simple list with a text column that has a url value. We had a simple icon and text string formatting allowing users to click and launch the link. Prior to the New List experience being rolled out to SharePoint this wasn't a problem. Now the icon and text don't launch the link, but clicking in the white space around the the cell does launch the link.

Previously the field looked like this: image

I found a workaround by adding "txtContent": "Open Files", to top elm level which removes the icon and text and just hyperlinks the text.

So now with the field looking like this it works: image

Below is the JSON, I've commented where I added the "txtContent": "Open Files",

{ "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json", "elmType": "a", //ADDING THIS ROW FIXES THE ISSUE
"txtContent": "Open Files", //But it should work without it. "attributes": { "href": "=if(@currentField=='','',@currentField", "class": "ms-fontColor-themePrimary ms-fontColor-themeDark--hover", "title": "='Open files" }, "style": { "text-decoration": "none" }, "children": [ { "elmType": "span", "attributes": { "iconName": "FileRequest" }, "style": { "padding-right": "4px" } }, { "elmType": "span", "txtContent": "=if(@currentField=='','','Open Files'" } ] }

Steps to reproduce

  1. Create a text string column and populate it with a URL
  2. Use the following JSON, which previously worked perfectly

{ "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json", "elmType": "a", "attributes": { "href": "=if(@currentField=='','',@currentField", "class": "ms-fontColor-themePrimary ms-fontColor-themeDark--hover", "title": "='Open files" }, "style": { "text-decoration": "none" }, "children": [ { "elmType": "span", "attributes": { "iconName": "FileRequest" }, "style": { "padding-right": "4px" } }, { "elmType": "span", "txtContent": "=if(@currentField=='','','Open Files'" } ] }

  1. Then try clicking the link, it doesn't launch the URL when clicking on the text. But it does launch when clicking around the text - in the white space.

Expected behavior

I have other scenarios where we have used images rather than icons and they also don't launch the links, although hovering displays the URL.

image

jgupta-msft commented 1 month ago

@ian-custom365 : Sorry for responding later here, but i hope these issues have been fixed for you. Please let me know if you are still facing some issues.