I have pretty simple Custom Modal LWC. I want it to navigate to Customer Portal Home Page onclose of the modal. Below is the code:
import LightningModal from 'lightning/modal';
import {NavigationMixin} from "lightning/navigation";
export default class DonorRegistrationModal extends NavigationMixin(LightningModal) {
handleOkay() {
this.close('okay');
this.navigateToHomePage();
}
navigateToHomePage() {
this[NavigationMixin.Navigate]({
type: 'comm__namedPage',
attributes: {
name: 'Home'
}
})
}
}
So, when clicking OK button I expect the modal to close and the page to be redirected to Home Page.
Actually I get exception.
Uncaught (in promise) Error: LWR4002: Could not find context to perform navigation action.
I cannot find any information regarding this exception.
Can somebody help me?