Preventing Internal Page Navigation in Jira

I want in my app to prevent users from navigating away from the current page if they have unsaved changes. My app uses react-router-dom v6 and I’ve already implemented a beforeunload event to handle cases where the user tries to close the browser tab or navigate outside of Jira.

However, this solution doesn’t work for internal Jira navigation, like moving between sections, for example from my app to view all projects.

I considered listening for all link clicks and manually preventing navigation, but that seems inefficient, and I’m wondering if there’s a better way using react-router or other available tools.