Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using FluentUI2: Unable to change Modal size #5454

Open
stsrki opened this issue Apr 11, 2024 Discussed in #5450 · 7 comments
Open

Using FluentUI2: Unable to change Modal size #5454

stsrki opened this issue Apr 11, 2024 Discussed in #5450 · 7 comments
Assignees
Labels
Type: Bug 🐞 Something isn't working
Projects
Milestone

Comments

@stsrki
Copy link
Collaborator

stsrki commented Apr 11, 2024

Discussed in #5450

Originally posted by DomenicoFormoso April 10, 2024
In version 1.5.1 of FluentUI I found the same problem found on material and then solved here:
#5063

@stsrki stsrki added the Type: Bug 🐞 Something isn't working label Apr 11, 2024
@stsrki stsrki added this to the 1.5 support milestone Apr 11, 2024
@stsrki stsrki self-assigned this Apr 11, 2024
@stsrki stsrki added this to 🔙 Backlog in Support via automation Apr 11, 2024
@stsrki
Copy link
Collaborator Author

stsrki commented Apr 17, 2024

@David-Moreira, I need your help with this one. For some reason, when the ModalProvider passes the Size parameter to the ModalContent, which is used by the Fluent provider, it seems to never change after that. I cannot figure out what is wrong.

@David-Moreira
Copy link
Contributor

@David-Moreira, I need your help with this one. For some reason, when the ModalProvider passes the Size parameter to the ModalContent, which is used by the Fluent provider, it seems to never change after that. I cannot figure out what is wrong.

hmm do you have a branch open with the attempt?

@stsrki
Copy link
Collaborator Author

stsrki commented Apr 17, 2024

I just did this in the demo

public async Task ShowStateful()
{
    if ( statefulModalInstance is null )
    {
        statefulModalInstance = await ModalService.Show<Counter>( "My Stateful content", new ModalInstanceOptions()
        {
            Stateful = true,
            RenderMode = ModalRenderMode.LazyLoad,
+            Size = ModalSize.ExtraLarge,
        } );

        return;
    }

    await ModalService.Show( statefulModalInstance );
}

@David-Moreira
Copy link
Contributor

Strange I believe I've seen that work. Is it happening provider specifically?

@stsrki
Copy link
Collaborator Author

stsrki commented Apr 17, 2024

Yes. For the Fluent provider, I had to propagate the Size from ModalContent to the Modal parent component.

@David-Moreira
Copy link
Contributor

David-Moreira commented Apr 17, 2024

It seems like the custom handlers in FluentUI to propagate the Size from ModalContent to the Modal parent component only propagate on an actual change.
Since the ModalProvider renders on demand, the Size parameter will already start defined as Extra Large and will not be detected as a change.

I added the OnInitialized with similar code and it seems to work properly. Can you verify?

protected override void OnInitialized()
    {
        if ( ParentModal is FluentUI2.Components.Modal fluentModal )
        {
//EDIT: Maybe adding a Size != Default on initialization would be okay to avoid running this code on defaults.
            fluentModal.NotifyModalSizeChanged( Size );
            fluentModal.NotifyModalCenteredChanged( Centered );
        }

        base.OnInitialized();
    }

image

@stsrki
Copy link
Collaborator Author

stsrki commented Apr 19, 2024

It still doesn't work as expected. It remembers the last size and shows XL for all opened modal instances If you go to the demo tests/modal-provider, and update

public async Task ShowStateful()
{
    if ( statefulModalInstance is null )
    {
        statefulModalInstance = await ModalService.Show<Counter>( "My Stateful content", new ModalInstanceOptions()
        {
            Stateful = true,
            RenderMode = ModalRenderMode.LazyLoad,
            Size = ModalSize.ExtraLarge,
        } );

        return;
    }

    await ModalService.Show( statefulModalInstance );
}

launch and click on

image

Now click on any other demo and it will still show as XL modal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug 🐞 Something isn't working
Projects
Support
  
🔙 Backlog
Development

No branches or pull requests

2 participants