Skip to content

Add intellisense support for new data-enhance, data-enhance-nav, and data-permanent Blazor attributes in .NET 8 #9378

@danroth27

Description

@danroth27

In .NET 8 RC2 we introduced some new attributes that Blazor users can use to control enhanced navigation and form handling:

  • data-enhance-nav: Used to turn off enhanced navigation for a specific link or DOM subtree

    <a href="my-non-blazor-page" data-enhance-nav="false">My Non-Blazor Page</a>
  • data-enhance: Used to opt in to enhanced form handling for a form element:

    <form method="post" @onsubmit="() => submitted = true" @formname="name" data-enhance>
        <AntiforgeryToken />
        <InputText @bind-Value="Name" />
        <button>Submit</button>
    </form>
    
    @if (submitted)
    {
        <p>Hello @Name!</p>
    }
    
    @code{
        bool submitted;
    
        [SupplyParameterFromForm]
        public string Name { get; set; } = "";
    }
  • data-permanent: Used to signal that an element add or updated dynamically should be preserved when handling an enhanced navigation of form request:

    <div data-permanent>
        This div gets updated dynamically by a script when the page loads!
    </div>

We should update the Razor tooling to provide appropriate completions and diagnostic for these attributes.

Related PRs:

Metadata

Metadata

Assignees

Labels

area-compilerUmbrella for all compiler issuesfeature requestLarge improvement request

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions