Skip to content

New sample because a document library in aTeams tab doesn't load URLs properly for .url items. #751

@robAttrell

Description

@robAttrell

Sample (which sample are you talking about)

I'm talking about a new sample using the 'Name' column in document libraries.

Suggestion (the more details, the better)

Currently, when you click on a .url 'file' in a Teams tab, the URL doesn't load and nothing happens. I'd love to suggest that be patched, but in the meantime, I wrote a column format for the Name column in document library that behaves and looks normal for all other files types, but if the file extension ends with '.url', it loads a standard tag that looks the same in the library but loads the correct shortcut URL in a new browser window with the href attribute and target is _blank. Testing indicates this works pretty well and overrides the default buggy behaviour in a Teams tab, without affecting anything else, if even looks the same.

The list of classes is just the default list of classes for a document library's Name column, so it looks and behaves the same as an ordinary name column in a document library. If you think I should post this bug somewhere Microsoft devs can see it, I'm happy to do that as well, but in the meantime, this is my fix.

Here is the formatting:

{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"children": [
{
"elmType": "a",
"attributes": {
"class": "ms-Link root_137a7565 nameField_c45bee6b clickable_c45bee6b overflow_85ed223c pre_85ed223c",
"href": "[$_ShortcutUrl]",
"target": "_blank"
},
"style": {
"display": "=if(endsWith([$FileLeafRef], '.url'), 'grid', 'none'",
"vertical-align": "middle"
},
"txtContent": "[$FileLeafRef]"
},
{
"elmType": "button",
"attributes": {
"class": "ms-Link root_137a7565 nameField_c45bee6b clickable_c45bee6b overflow_85ed223c pre_85ed223c"
},
"style": {
"display": "=if(endsWith([$FileLeafRef], '.url'), 'none', 'grid'",
"vertical-align": "middle"
},
"txtContent": "[$FileLeafRef]",
"customRowAction": {
"action": "defaultClick"
}
}
]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions