Skip to content

[dev-v5] fix: FluentAnchorButton is causing multiple events #4697

@MarvinKlein1508

Description

@MarvinKlein1508

🐛 Bug Report

💻 Repro or Code Sample

Use this code:

<NavigationLock OnBeforeInternalNavigation="OnBeforeInternalNavigation" />

<FluentSwitch @bind-Value="preventNavigation" Label="Prevent navigation" />

<FluentAnchorButton Href="/">Home</FluentAnchorButton>

<a href="/">Home</a>

@code {
    private bool preventNavigation = true;
    private void OnBeforeInternalNavigation(LocationChangingContext context)
    {
        Console.WriteLine("Executed");
        if (preventNavigation)
        {
            context.PreventNavigation();
        }
    }
}
  1. Navigate to page in the demo project
  2. Open console
  3. Click the FluentAnchorButton
  4. See two outputs
  5. Click the normal a tag
  6. See only one output

🤔 Expected Behavior

I expect the console to show only 1 output

😯 Current Behavior

We have two outputs in the console

💁 Possible Solution

🔦 Context

This could be related to the underlying web components. I haven't seen any click logic within the razor files.

🌍 Your Environment

  • OS & Device: Windows 11 64 Bit
  • Browser Latest Firefox and Chrome/Edge
  • latest dev-v5 branch

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA bugv5For the next major version

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions