Skip to content

fix: messages not auto cleared after navigation in FluentMessageBarProvider #2867

@markoweb2

Description

@markoweb2

🐛 Bug Report

Even though <FluentMessageBarProvider ClearAfterNavigation="true" /> is set, messages are not cleared on navigation.

💻 Repro or Code Sample

Default Visual Studio Blazor Web App project.

MainLayout.razor

    <main>
        <div class="top-row px-4">

        </div>

        <article class="content px-4">
            <FluentMessageBarProvider ClearAfterNavigation="true" />
            @Body
        </article>
    </main>

On the home page in a button click handler I have:
MessageService.ShowMessageBar("just some info");

Navigating to other pages does not do what ClearAfterNavigation="true" states it should do.

🤔 Expected Behavior

I would expect messages to dissapear after navigating.

😯 Current Behavior

Image

🔦 Context

Just want to show a message on one page, and if the user goes to another page, the message should dissapear.
Documentation is not very clear on this topic.

Looking at the docs, the Section parameter is also confusing. If you only have one FluentMessageBarProvider entity for you entire project, sitting at MainLayout.razor, then what is the purpose of Section filtering out messages?

  • Is the idea here, that you bind a parameter to Section and say with a button click, change it's value and now different messages get shown?
  • Or is the idea that you place a FluentMessageBarProvider to every page, give each a different section, and when in your background task/service a message needs to be shown, you tag it with a Section value and it automatically bubbles up to the correct page?

I bring this up, because I wonder if ClearAfterNavigation also ties in with having to create FluentMessageBarProvider-s on every page (not one global singleton in MainLayout like the documentation suggests). Then if ClearAfterNavigation="true" is set, you navigate away and come back, then that specific FluentMessageBarProvider instance on that page will have cleared its messages...

🌍 Your Environment

  • OS = Windows
  • Browser = Google Chrome
  • .NET and Fluent UI Blazor library Version = 8.0.10 and 4.10.2
  • Visual Studio 2022 (17.11.5)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions