You can't block the "disable confirmation" checkbox, as said in may other answers, it's a browser feature.
However, reading between the lines of your question, it looks like you probably don't want to break functionality, if the user does disable confirmation dialogues.
A simple drop in solution is to build a confirmation that defaults to true when disabled.
i.e. If the user disables confirmation dialogues, we assume that means the user doesn't want to have to confirm, not that the user wants to reject everything that might ask for confirmation.
// web/src/utils/blocked-to-true-confirm.js
/**
* Simple wrapper around window.confirm that returns true if the
* confirm dialog is blocked.
*/
export function blockedToTrueConfirm(message) {
const startTime = Date.now()
const result = window.confirm(message)
const endTime = Date.now()
// If the confirm returns faster than a human could possibly click
// (e.g., in 1 millisecond), assume it's been blocked
if (endTime - startTime < 1) {
return true
}
return result
}
export default blockedToTrueConfirm
Usage would be something like
// a red x on some data table component that lets you delete table rows
<v-btn
title="Delete"
icon
color="red"
@click="deleteHotel(item)"
><v-icon>mdi-close</v-icon></v-btn
>
async function deleteHotel(hotel) {
if (!blockedToTrueConfirm("Are you sure you want to remove this hotel?")) return
try {
await travelDeskHotelsApi.delete(hotel.id)
} catch (error) {
console.error(error)
}
}
e.g. https://github.com/icefoganalytics/travel-authorization/commit/df86563b6824c2f93d025123aa0a8fd640bc5501