Megabit / Blazorise

Blazorise is a component library built on top of Blazor with support for CSS frameworks like Bootstrap, Tailwind, Bulma, AntDesign, and Material.
https://blazorise.com/
Other
3.18k stars 517 forks source link

[Bug]: BlazorWebAssembly MessageProvider not displaying the confirmation dialog #5521

Closed yarutyunov closed 1 month ago

yarutyunov commented 1 month ago

Blazorise Version

1.5.2

What Blazorise provider are you running on?

Bootstrap4

Link to minimal reproduction or a simple code snippet

https://github.com/yarutyunov/BlazorWebAssemblyConfirmation/tree/notworking-net8

Steps to reproduce

  1. Launch App
  2. Click on 'Show confirmation dialog' button

What is expected?

When 'Show confirmation dialog' button is clicked a Confirmation Dialog displays

What is actually happening?

Page becomes disabled and requires reload

What browsers do you see the problem on?

Chrome, Microsoft Edge

Any additional comments?

Working net7 version: https://github.com/yarutyunov/BlazorWebAssemblyConfirmation/tree/working-net7

No response

stsrki commented 1 month ago

There are several things you forgot to include in your project.

1. index.html

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>BlazorApp1</title>
    <base href="/" />
    <link rel="icon" type="image/png" href="favicon.png" />

    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">
    <link href="_content/Blazorise.Icons.FontAwesome/v6/css/all.min.css" rel="stylesheet">

    <link href="_content/Blazorise/blazorise.css" rel="stylesheet" />
    <link href="_content/Blazorise.Bootstrap5/blazorise.bootstrap5.css" rel="stylesheet" />

    <link rel="stylesheet" href="css/app.css" />
    <link href="BlazorApp1.styles.css" rel="stylesheet" />
</head>

<body>
    <div id="app">
        <svg class="loading-progress">
            <circle r="40%" cx="50%" cy="50%" />
            <circle r="40%" cx="50%" cy="50%" />
        </svg>
        <div class="loading-progress-text"></div>
    </div>

    <div id="blazor-error-ui">
        An unhandled error has occurred.
        <a href="" class="reload">Reload</a>
        <a class="dismiss">🗙</a>
    </div>
    <script src="_framework/blazor.webassembly.js"></script>
</body>

</html>

Bootstrap5 Nuget packages

<ItemGroup>
  <PackageReference Include="Blazorise" Version="1.5.2" />
  <PackageReference Include="Blazorise.Bootstrap5" Version="1.5.2" />
  <PackageReference Include="Blazorise.Components" Version="1.5.2" />
  <PackageReference Include="Blazorise.Icons.FontAwesome" Version="1.5.2" />
  <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.3" />
  <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.3" PrivateAssets="all" />
</ItemGroup>

Adjust code to use BS5

using BlazorApp1;
using Blazorise;
using Blazorise.Bootstrap5;
using Blazorise.Icons.FontAwesome;
using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;

var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("#app");
builder.RootComponents.Add<HeadOutlet>("head::after");

builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });

builder.Services
    .AddBlazorise(options =>
    {
        options.Immediate = true;
    })
    .AddBootstrap5Providers()
    .AddFontAwesomeIcons();

await builder.Build().RunAsync();
yarutyunov commented 1 month ago

Thank you! it worked