[SalesForce] Lightning Tile Link Refreshes Console

I have a lightning component that's display search results using lightning:tile, which has an href parameter (no onclick). The component is on the account page in the service console (lightning view) and the problem is clicking the link in the tile causes the entire console to reload (bad) and then the link opens in a new primary tab (good).

Here's the code:

<lightning:tile label="{!article.UrlName}" href="{!'/lightning/r/Knowledge__kav/' + article.Id + '/view'}">
    <ul class="slds-list_horizontal slds-has-dividers_right">
        <li class="slds-item">{!article.Title}</li>
    </ul>
</lightning:tile>

Is there a way to prevent the console from reloading? Or can that not be done using tiles?

Best Answer

According to the documentation, if you want to open other tabs or subtabs within the console, you should be Using Page References to Open Console Workspace Tabs and Subtabs.

Example of controller for opening a subtab:

({
    openSubtab: function(component, event, helper) {
        var workspaceAPI = component.find("workspace");
        workspaceAPI.openSubtab({
            pageReference: {
                "type": "standard__component",
                "attributes": {
                    "componentName": "c__greetings"
                },
                "state": {
                    "uid": "1",
                    "c__name": component.get("v.myName")
                }
            }
        }).then(function(tabId) {
            console.log("The new subtab ID is:" + tabId);
        }).catch(function(error) {
            console.log("error");
        });
    }
})

So, href="{!'/lightning/r/Knowledge__kav/' should be avoided

Related Topic