Skip to content

OnInput intermittently not working #19299

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

Closed
dotnetKyle opened this issue Feb 24, 2020 · 2 comments
Closed

OnInput intermittently not working #19299

dotnetKyle opened this issue Feb 24, 2020 · 2 comments
Labels
area-blazor Includes: Blazor, Razor Components ✔️ Resolution: Duplicate Resolved as a duplicate of another issue Status: Resolved

Comments

@dotnetKyle
Copy link

Describe the bug

When I set an OnInput action that modifies the incoming input, the change I have made is not reflected in the UI.

To Reproduce

<label>MyString: </label>
<input type="text" @oninput="inputFilter" value="@myString" />
@code {
    private string myString { get; set; }
    private void inputFilter(ChangeEventArgs args)
    {
        if(args.Value != null)
        {
            var value = args.Value.ToString();
            myString = value.Replace("a", "");
        }
    }
}

Now run the application, type into the textbox some text, then type an 'a' character. If reproduced, the 'a' does not get replaced until you type another VALID character. Odd behavior. No exceptions are thrown. Try typing several a's in a row; then type another character.

Note: I have seen this related issue/work around (#17702 (comment)), not 100% certain that it applies here but it does work around my problem at the moment.

Further technical details

  • .NET Core 3.1
  • Running in Visual Studio Professional 16.4.5
  • Output of dotnet --info
.NET Core SDK (reflecting any global.json):
 Version:   3.1.101
 Commit:    b377529961

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.18363
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\3.1.101\

Host (useful for support):
  Version: 3.1.1
  Commit:  a1388f194c

.NET Core SDKs installed:
  2.1.202 [C:\Program Files\dotnet\sdk]
  2.1.509 [C:\Program Files\dotnet\sdk]
  2.1.511 [C:\Program Files\dotnet\sdk]
  3.1.101 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.15 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.15 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.13 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.1.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
@dotnetKyle
Copy link
Author

dotnetKyle commented Feb 24, 2020

Note to all looking for a work-around, this is the code I am writing to get it working for the moment:

MyString: <input type="text" @bind-value="MyString" @bind-value:event="oninput"/>
string _myString { get; set; }
string MyString
{
    get
    {
       return _myString;
    }
    set
    {
        _myString = value.Replace("a", "");
    }
}

@javiercn javiercn added the area-blazor Includes: Blazor, Razor Components label Feb 25, 2020
@mkArtakMSFT mkArtakMSFT added the ✔️ Resolution: Duplicate Resolved as a duplicate of another issue label Feb 25, 2020
@mkArtakMSFT
Copy link
Member

Thanks for contacting us. This is a dupe of #17281.

@ghost ghost added the Status: Resolved label Feb 25, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Mar 26, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Includes: Blazor, Razor Components ✔️ Resolution: Duplicate Resolved as a duplicate of another issue Status: Resolved
Projects
None yet
Development

No branches or pull requests

3 participants