Stop closing of the max-modal whenever there are unsaved changes

Hi I am using max-modal with app-bridge 4.0 verison and whenever there are changes in the modal I show a UI save bar now in this instance if somebody clicks outside the modal it closes But I want to show a confirmation modal asking them if they are sure and saved changes will be lost but there is nothing in the docs of the UI save bar and UI modal that would allow us to achieve this.
https://shopify.dev/docs/api/app-bridge-library/apis/save-bar
https://shopify.dev/docs/api/app-bridge-library/web-components/ui-modal

Did you find the solution?