microsoft / fluentui-blazor

Microsoft Fluent UI Blazor components library. For use with ASP.NET Core Blazor applications
https://www.fluentui-blazor.net
MIT License
3.87k stars 376 forks source link

Issue upgrading from 4.2.1 to 4.3.0 #1294

Closed VishwamKumar closed 10 months ago

VishwamKumar commented 10 months ago

Here is an example, as how you can create this issue

  1. Create a Blazor Server App using Fluent Blazor Web App template
  2. Sample pages like counter and weather pages works fine

πŸ› Bug Report

  1. Check the the following packages, if you are using this (which is my working project does)
  2. Once you upgrade the nuget packages which either shows like
  3. For example, add the following login test page, if package is 4.2.1, it works fine, validation and submit button fires, but the moment you upgrade to 4.3.0, they stop, if you revert back to 4.2.1., all starts working again. sharing the sample login page here

πŸ’» Repro or Code Sample


@page "/Login"
@rendermode InteractiveServer
@using Microsoft.AspNetCore.Components.Web;
@using System.ComponentModel.DataAnnotations;

<PageTitle>Login</PageTitle>
<FluentLabel Typo="Typography.PageTitle">Login</FluentLabel>
<hr />
<FluentCard Id="loginCard" >
    <EditForm Model="@LoginUsr" OnValidSubmit="SubmitLoginAsync" FormName="LoginForm">
         <label for="UserName" class="bold-text">User Name: *</label><br />
         <input Id="UserName" Placeholder="Enter your user name" Required @bind="@LoginUsr.UserName" Size="40" Minlength="6" /><br />
         <label for="UserPassword" class="bold-text">Password: *</label><br />
         <input Id="UserPassword" Placeholder="Enter your password" Required @bind="@LoginUsr.Password" Size="40" Minlength="7" type="Password" autocomplete="new-password" /><br />
         <div style="margin:24px 0px;">
            <FluentButton Id="btnSubmit" Appearance="Appearance.Accent" Type="ButtonType.Submit">Login</FluentButton><br /><br />
            <FluentLabel Id="loginMessage">@LoginStatusMessage</FluentLabel>
        </div>
    </EditForm>
</FluentCard>

```@code
{
    private LoginUser LoginUsr = new();
    private string LoginStatusMessage = "";

    private class LoginUser
    {
        [Required]
        [EmailAddress]
        public string UserName { get; set; } = string.Empty;

        [Required]
        [DataType(DataType.Password)]
        public string Password { get; set; } = string.Empty;
    }
    private async Task SubmitLoginAsync()
    {
        try
        {
            if (LoginUsr.UserName.Length > 0 && LoginUsr.Password.Length > 0)
            {
                LoginStatusMessage = "Please wait...while login is being validated.";
                await Task.Delay(300);
                LoginStatusMessage = "Login Successful.";
            }
            else
            {
                LoginStatusMessage = "Login failed.";
            }
        }
        catch (Exception ex)
        {
            LoginStatusMessage = ex.Message;
            LoginStatusMessage = "Sorry! An error occured, please try again later.";
        }
    }

}## πŸ€” Expected Behavior

Upgrade should continue working with existing code, unless if any changes i need to make somewhere

## 😯 Current Behavior
It breaks on upgrade

## πŸ’ Possible Solution

Have not found yet

## πŸ”¦ Context

I am working on developing a blazor server based blog incorporating fluent UI controls. Here is the working version - with 4.2.1 - https://fluentblog.azurewebsites.net
Wanted to upgrade it to latest version and it breaks

## 🌍 Your Environment

Upgraded locally and used both Edge and Chrome browser using Windows 10 with VS 2022 latest version.

* OS & Device: [e.g. MacOS, iOS, Windows, Linux] on [iPhone 7, PC]
* Browser [e.g. Microsoft Edge, Google Chrome, Apple Safari, Mozilla FireFox]
* .NET and FAST Version [e.g. 1.8.0]
vnbaaij commented 10 months ago

In v4.3 we added a fix for being able to use a FluentButton to submit a form when the button is located outside of the EditForm. Because of this fix, it is now required that the EditForm has an id set. So, as a workaround, for now, if you add an id to the EditForm, it all starts to work again. We will see if we can fix this in a better way for v4.3.1

VishwamKumar commented 10 months ago

Thanks @vnbaaij , that worked