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

Form formatting: In header section [$FileLeafRef], [$FileRef] coming blank #7964

Open NWH-SAmin5 opened 2 years ago

NWH-SAmin5 commented 2 years 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

Describe the bug / error

Form formatting: In header section [$FileLeafRef], [$FileRef] coming blank

Steps to reproduce

  1. Create document library: TestDocLib
  2. Upload sample PDF file
  3. Open Properties form by clicking file three dots > More > Properties > Configure layout > Header
  4. Add this JSON in header
{
    "elmType": "div",
    "attributes": {
        "class": "ms-borderColor-neutralTertiary"
    },
    "style": {
        "width": "99%",
        "border-top-width": "0px",
        "border-bottom-width": "1px",
        "border-left-width": "0px",
        "border-right-width": "0px",
        "border-style": "solid",
        "margin-bottom": "16px"
    },
    "children": [
        {
            "elmType": "div",
            "style": {
                "display": "flex",
                "box-sizing": "border-box",
                "align-items": "center"
            },
            "children": [
                {
                    "elmType": "div",
                    "attributes": {
                        "iconName": "PDF",
                        "class": "ms-fontSize-24 ms-fontWeight-regular ms-fontColor-themePrimary",
                        "title": "PDF file"
                    },
                    "style": {
                        "flex": "none",
                        "padding": "0px",
                        "padding-left": "0px",
                        "height": "24px"
                    }
                }
            ]
        },
        {
            "elmType": "div",
            "attributes": {
                "class": "ms-fontColor-neutralPrimary ms-fontWeight-bold ms-fontSize-24"
            },
            "style": {
                "box-sizing": "border-box",
                "text-align": "left",
                "padding": "21px 12px",
                "overflow": "hidden"
            },
            "children": [
                {
                    "elmType": "div",
                    "txtContent": "[$FileLeafRef]"
                }
            ]
        },
        {
            "elmType": "a",
            "attributes": {
                "class": "ms-fontColor-themePrimary ms-fontColor-themeDark--hover",
                "title": "Fullscreen Preview",
                "target": "_blank",
                "href": "[$FileRef]"
            },
            "style": {
                "border": "none",
                "background-color": "transparent",
                "cursor": "pointer",
                "text-decoration": "none"
            },
            "children": [
                {
                    "elmType": "span",
                    "style": {
                        "text-align": "center",
                        "display": "table-cell",
                        "vertical-align": "middle",
                        "font-size": "20px"
                    },
                    "attributes": {
                        "iconName": "OpenInNewTab"
                    }
                }
            ]
        }
    ]
}

Expected behavior

What Should Happen

Form header should display PDF icon, File name, Open in new tab icon image

Open in new tab icon should be linked to file url using [$FileRef]

What Actually Happens

Form header is showing only two icons, it is not displaying file name using [$FileLeafRef] image

Open in new tab icon href attribute does not have url, so clicking on this icon does not do anything

ghost commented 2 years ago

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

ganesh-sanap commented 1 year ago

I have also observed this issue while formatting header layout in properties form of SharePoint document library.

Using [$FileLeafRef] resulting in blank value even when it is available in page context: image

watana2 commented 6 months ago

Issue still present in 2024.

isomna72 commented 1 month ago

August 2024, still not working. Is there any other idea, how to display a Link to the Document in the Header?