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 1k forks source link

customRowAction - defaultClick not working for long urls in webpart view #8488

Open NWH-SAmin5 opened 1 year ago

NWH-SAmin5 commented 1 year 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

Microsoft Edge Version 106.0.1370.30 (Official build) beta (64-bit)

Describe the bug / error

In a document library, when you create "Link" item with very long url (approx 300+ length) and add JSON formatting for an additional column which has "defaultClick" as customRowAction

"elmType": "button",
"customRowAction": {
  "action": "defaultClick"
}

default click to open the link is not working when added as document library webpart view

Note: defaultClick is working in actual document library view page e.g. /Allitems.aspx

Steps to reproduce

  1. Create a document library
  2. Add new column "LinkText"
  3. Create "Link" item, use a very long url e.g. https://www.google.com/search?q=long+url&oq=long+url&aqs=edge..69i57j0i512l7j69i64.1651j0j1&sourceid=chrome&ie=UTF-8&p_p_mode=view&refererPlid=2547752&saveLastPath=false&_com_liferay_login_web_portlet_LoginPortlet_mvcRenderCommandName=/login/login&p_p_id=com_liferay_login_web_portlet_LoginPortlet&p_p_lifecycle=0&_com_liferay_login_web_portlet_LoginPortlet_redirect=/group/welllwell&safe=active&ssui=on
  4. Add column formatting to "LinkText"
    {
    "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
    "elmType": "div",
    "style": {
    "display": "table",
    "width": "100%"
    },
    "children": [
    {
      "elmType": "div",
      "style": {
        "display": "table-cell",
        "text-align": "center",
        "vertical-align": "middle"
      },
      "children": [
        {
          "elmType": "button",
          "customRowAction": {
            "action": "defaultClick"
          },
          "attributes": {
            "class": "ms-fontColor-themePrimary ms-fontColor-themeDark--hover",
            "title": "[$FileLeafRef]"
          },
          "style": {
            "border": "none",
            "background-color": "transparent",
            "cursor": "pointer"
          },
          "children": [
            {
              "elmType": "img",
              "attributes": {
                "src": "=if([$File_x0020_Type] == 'url', 'https://res-1.cdn.office.net/files/fabric-cdn-prod_20220825.001/assets/item-types/20/link.svg', 'https://res-1.cdn.office.net/files/fabric-cdn-prod_20220825.001/assets/item-types/20/' + [$File_x0020_Type] + '.svg')"
              },
              "style": {
                "width": "20px",
                "height": "20px"
              }
            }
          ]
        }
      ]
    }
    ]
    }
  5. Create a new page
  6. Add "Document library" webpart and select this document library
  7. Click on the link item created in step 3 from the page

Expected behavior

By clicking the link item from webpart document library view, it should open the link in a new tab

ghost commented 1 year ago

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.