Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
onNavigate = callback => {
// We don't warn about discarding changes when fullScreen, e.g. a login page
const menuItem = this.state.menuItem;
if (
menuItem &&
menuItem.content.has('dirty') &&
menuItem.content.get('dirty') &&
!menuItem.fullScreen
) {
// Show a confirmation dialog to see if the user wants to continue
globals.displayConfirmation({
title: 'Discard changes?',
callback
});
} else {
// Nothing is dirty so allow the navigation to continue
callback(true);
}
};