Basaingeal / Razor.SweetAlert2

A Razor class library for interacting with SweetAlert2

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Target property in SweetAlertOptions doesn't appear to be working

waterfausett opened this issue · comments

Describe the bug

When using the Target property of SweetAlertOptions, the resulting alert isn't coming from the given target as expected.

To Reproduce

@inject SweetAlertService Swal
...
await Swal.FireAsync(new SweetAlertOptions
{
    Target = ".main",
    Icon = SweetAlertIcon.Error,
    Title = "Title",
    Html = "Message",
    ConfirmButtonText = "Ok",
});

Expected behavior
The alert should "come from" the target element. (be centered in etc.)

Apologies for the false alarm - turns out I misunderstood how sweetalert2 handles the target property under-the-hood.

It just appends the .swal2-container to target if supplied, but the container still has position: fixed. Any styling desired (such as having the alert centered in it's parent) needs to be managed by the user.