JavaScript Confirm method always dismissed

Hello,

I have issue testing one page, It use JavaScript for confirmation:
var choice = confirm(“The selected documents will now be finalized!”);
if (choice == false) {
return;
}

After this check it runs AJAX and documents are finalized.
Issue is that whenever this confirm is run, playwright dismiss it.
I found in their docs:
By default, dialogs are auto-dismissed by Playwright, so you don’t have to handle them. However, you can register a dialog handler before the action that triggers the dialog to either dialog.accept() or dialog.dismiss() it.

page.on('dialog', dialog => dialog.accept());await page.getByRole('button').click();

I also found Handle Future Dialogs but also do not work.

Is there a way to pervent new browser to dismiss dialogs?

Hey I am in the same pickle, the Handle Future Dialogs doesn’t even close (dismiss) the alert for me. The test gets stuck with the popup open