Skip to content

fix: When data binding, Value is not updated before @onchange is called #472

@mrpmorris

Description

@mrpmorris

Example: In the demos layout

  1. A Task.Delay is required to allow the binding to occur before we know the value.
    public async void SwitchTheme()
    {
        await Task.Delay(50);
  1. The code is tracking state rather than using the field _ltr that is bound to.
    public async Task SwitchDirection()
    {
        dir = (dir == LocalizationDirection.rtl) ? LocalizationDirection.ltr : LocalizationDirection.rtl;

This was a problem that was solved in .Net 7 when @bind-Value:after was introduced. However, because we need to continue to support .Net 6 this cannot be used.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions