svelte-simple-modal icon indicating copy to clipboard operation
svelte-simple-modal copied to clipboard

Modal closes automatically after JS native confirm()

Open stefan-golus opened this issue 9 months ago • 4 comments
trafficstars

Issue:

When using a confirmation dialog in a component opened within a modal, the modal closes automatically upon confirmation. This behavior is illustrated in the following code snippet:

Code:

<!-- ContentForModal.svelte -->
[...]
<script>
  function invokeActionWithNativeJsConfirm() {
  	if (confirm('Are you sure?')) {
  		console.log('im sure');
  	}
  }
</script>

[...]

<button
	type="button"
	on:click={() => {
		invokeActionWithNativeJsConfirm();
	}}>Delete
</button>

Steps to reproduce:

  • Open the component in a modal.
  • Trigger handleRemoveAddressClick.
  • Confirm the action in the dialog.

Expected behavior: The modal should remain open after the confirmation dialog is handled.

Actual behavior: The modal closes automatically after the confirmation.

stefan-golus avatar Jan 31 '25 13:01 stefan-golus