Summary
I work on a SFDX project with one package, and within my aura component,
I'm currently having problems with the lightning:navigation
element. I followed the docs from Aura Component - Navigation but still my button does not redirect me as expected.
Details & what I've tried
I do have this line in my aura component :
<lightning:button label="Navigate" onclick="{!c.handleClick}"/>
And then, my js controller does the following :
handleClick: function(cmp, event, helper) {
event.preventDefault();
const navService = cmp.find("navService");
const pageReference = {
type: 'standard__objectPage',
attributes: {
objectApiName: 'Account',
actionName: 'list'
},
state: {
filterName: "Recent"
}
};
console.log(navService);
console.log(pageReference);
navService.navigate(pageReference);
}
So, when I'm clicking the button in my UI, this is the output of the 2 console.log()
above :
But no redirection is done.
So when I'm clicking my button that is supposed to redirect me to the page pageReference
:
- My navService is well initialized and has a navigate() function and is logged as shown above
- My pageReference is logged (see console output above, 2nd item)
- But the line
navService.navigate(pageReference);
does nothing (no redirection, no error, no log message.)
So my questions are :
- Am I missing something ?
- Is there something to configure in order to make the navService / lightning:navigation work as expected ?
- Why is there no redirection when I'm following the exact same code as the documentation ?
More specific details (possibly not relevant)
FYI my aura component (.cmp file) does have an implements
key like so :
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes">
Also, I don't know if this is relevant but my navigate() function of the navService displays the following elements in my console :
Exception: TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them at Function.invokeGetter
EDIT :
Also, please note that the Navigate
button is embedded into some kind of UtilityBar (flexipage), in the bottom left of the page.