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

List Formatting: When an `a` element is set as a child of a `div` element with `setValue` configured, `setValue` stops working

Open tecchan1107 opened this issue 1 year ago • 1 comments

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

  • [ ] 💥 Internet Explorer
  • [X] 💥 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

No response

Describe the bug / error

In order to investigate the count of link clicks, the a element was placed in the child element of the div element with setValue. Previously, the setValue worked and counted up, but it no longer works.

sample

Is this a bug? Or is it a specification?

Steps to reproduce

  1. Create a list
  2. Create a hyperlink column with any column name
  3. Create a number column with internal name ClickCount
  4. Apply the following JSON to the hyperlink column created in 2.
Column Formatting JSON
{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "div",
  "style": {
    "display": "=if(@currentField == '' , 'none' , '')"
  },
  "children": [
    {
      "elmType": "div",
      "customRowAction": {
        "action": "setValue",
        "actionInput": {
          "ClickCount": "= [$ClickCount] + 1"
        }
      },
      "children": [
        {
          "elmType": "a",
          "style": {
            "text-decoration": "none",
            "padding": "5px 10px 5px 10px",
            "font-weight": "bold",
            "border-radius": "5px",
            "font-size": "13px",
            "white-space": "nowrap"
          },
          "txtContent": "@currentField.desc",
          "attributes": {
            "href": "@currentField",
            "target": "_blank",
            "class": "ms-fontColor-themePrimary ms-bgColor-themeLighter ms-fontColor-white--hover ms-bgColor-themePrimary--hover"
          }
        }
      ]
    }
  ]
}

Expected behavior

When I click on the link, the link opens and setValue works as before.

screenshot

(The above video was retrieved from hyperlink-click-count.)

tecchan1107 avatar Oct 25 '24 23:10 tecchan1107

When I set the same JSON as now in the document library, setValue worked and ClickCount counted up.

sample

tecchan1107 avatar Oct 25 '24 23:10 tecchan1107

@tecchan1107 Thanks for reporting the issue. It is fixed and should be in prod in 2-3 weeks.

tpodugu-ms avatar Nov 20 '24 20:11 tpodugu-ms

@tpodugu-ms @VesaJuvonen Hello! I am also experiencing this issue in my environment and I am seeking a resolution. You mentioned that the fix would take 2-3 weeks, so I would like to check the current status of the progress.

myNCA-2024 avatar Dec 10 '24 06:12 myNCA-2024

@VesaJuvonen @myNCA-2024 Fix will reach to prod 100% in 1-2 days.

tpodugu-ms avatar Dec 10 '24 11:12 tpodugu-ms

I checked today and this issue has been fixed!

sample

@tpodugu-ms Thank you for your help and fixing this issue!

tecchan1107 avatar Dec 17 '24 03:12 tecchan1107