SharePoint / sp-dev-docs

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

List Formatting: Clicking on a child element of the `a` element does not open the linked site in the newer? Microsoft Lists #9753

Closed tecchan1107 closed 1 month ago

tecchan1107 commented 3 months ago

Target SharePoint environment

SharePoint Online

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

Declarative list formatting

Developer environment

Windows

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

Additional environment details

No response

Describe the bug / error

In the newer? Microsoft Lists, clicking on a child element of the a element does not open the linked site.

newer

In the older? Microsoft Lists, clicking on a child of the a element opens the linked site.

older

Steps to reproduce

  1. Create a list
  2. Create some items
  3. Format the view with the following JSON
JSON of view formatting ``` json { "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/row-formatting.schema.json", "hideSelection": true, "hideColumnHeader": true, "rowFormatter": { "elmType": "div", "children": [ { "elmType": "div", "style": { "font-size": "20px" }, "children": [ { "elmType": "div", "txtContent": "↓ a element" }, { "elmType": "a", "style": { "display": "flex", "justify-content": "center", "align-items": "center", "width": "500px", "height": "300px", "margin": "10px" }, "attributes": { "href": "https://learn.microsoft.com/en-us/sharepoint/dev/declarative-customization/formatting-syntax-reference", "target": "_blank", "class": "ms-bgColor-communicationTint20 ms-bgColor-communicationTint10--hover" }, "children": [ { "elmType": "div", "style": { "display": "flex", "justify-content": "center", "align-items": "center", "width": "50%", "height": "50%" }, "attributes": { "class": "ms-bgColor-sharedOrange10 ms-bgColor-sharedOrange20--hover" }, "children": [ { "elmType": "span", "attributes": { "iconName": "Link" } }, { "elmType": "span", "txtContent": "child element" } ] } ] } ] } ] } } ```
  1. Click on the parent or child element of the displayed link

image

Expected behavior

Clicking on a child element of the a element opens the linked site.

tecchan1107 commented 3 months ago

Perhaps this is occurring only in the list view. In the gallery view, this phenomenon did not occur.

patrikhellgren commented 3 months ago

I have been seeing the same thing the last week or so.

Using this json to display a button in a column that links to another page:

{
    "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
    "elmType": "div",
    "children": [
        {
            "elmType": "a",
            "attributes": {
                "class": "ms-fontColor-themePrimary ms-fontColor-themeDarker--hover",
                "href": "='https://contoso.sharepoint.com/sites/TestSite1/Lists/TestList1/AllItems.aspx?FilterField1=field1&FilterType1=Lookup&viewid=fb0fb875%2D5e69%2D4ef1%2Da68d%2D919bc53d1f44&FilterValue1=' + [$Title]"
            },
            "style": {
                "border": "none",
                "background-color": "transparent",
                "cursor": "pointer",
                "font-size": "12px"
            },
            "children": [
                {
                    "elmType": "span",
                    "attributes": {
                        "iconName": "FullHistory",
                        "title": "Show history"
                    },
                    "style": {
                        "padding-right": "6px"
                    }
                }
            ]
        }
    ]
}

This was working a week or so ago but had stopped working sometime during this last week.

Changing it to the following got it working again so my feeling is the same as yours that without child elements it seems to be working.

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/column-formatting.schema.json",
  "elmType": "div",
  "children": [
    {
      "elmType": "a",
      "attributes": {
        "class": "ms-fontColor-themePrimary ms-fontColor-themeDarker--hover",
        "iconName": "FullHistory",
        "title": "Show history",
        "href": "='https://arcticfalls.sharepoint.com/sites/Egenkontroller-dev/Lists/Utfrda%20Egenkontroller/AllItems.aspx?FilterField1=afacObjectLookup&FilterType1=Lookup&viewid=fb0fb875%2D5e69%2D4ef1%2Da68d%2D919bc53d1f33&FilterValue1=' + [$Title]"
      },
      "style": {
        "text-decoration": "none",
        "border": "none",
        "background-color": "transparent",
        "padding-left": "15px",
        "padding-right": "6px",
        "cursor": "pointer",
        "font-size": "12px"
      }
    }
  ]
}
ian-custom365 commented 3 months ago

Agree this is an issue and has been an issue for weeks - every tenant - and every user once the List App interface is deployed to SharePoint Lists it breaks any hyperlinked image field. Such as this one - which simply links to SPO Sites.

image

tecchan1107 commented 2 months ago

I just checked and this problem has been resolved!

sample

I also had no problems with the column formatting links.

sample

I will close this issue as I believe the problem has been resolved.

Thanks for the fix @shagra-ms @arkogupta 🙇‍♂️!!

tecchan1107 commented 2 months ago

I will mentions this to both of you who have had reactions on this thread and let you know. @Tanddant @Fedes365

Tanddant commented 2 months ago

Tagging @AlexanderHenkel cause I know he had some issues with this as well, but it seems to be working on my end

AlexanderHenkel commented 2 months ago

I can confirm that my formatted fields are working again, as intended

Tanddant commented 2 months ago

The issue is back on some of my tenants now 🙃

tecchan1107 commented 2 months ago

Thanks for letting us know, Dan! This issue has recurred in my environment too...😔😔😔 I will reopen this Issue.

tecchan1107 commented 1 month ago

I checked today and was able to open the link!

sample

Therefore, I am closing this issue.