Skip to content
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

Textfield swallowing chars when typing rapidly (only on server, not on wasm) #1012

Closed
henon opened this issue Feb 25, 2021 · 12 comments · Fixed by #1228 or #3002
Closed

Textfield swallowing chars when typing rapidly (only on server, not on wasm) #1012

henon opened this issue Feb 25, 2021 · 12 comments · Fixed by #1228 or #3002
Assignees
Labels
bug Something does not work as intended/expected fixed Fix has been merged
Milestone

Comments

@henon
Copy link
Collaborator

henon commented Feb 25, 2021

Describe the bug
This can be seen on mudblazor.com, type in the debounce example, type FAST! it will drop some chars.

related issues: #897

@henon henon added the bug Something does not work as intended/expected label Feb 25, 2021
@Garderoben
Copy link
Member

Seems to only happen on ServerSide Blazor or?
Is it possible to somehow only run the debouce after a certain amount of time after last key pressed? little hackiys maybe but seems to be a general blazor problem?

@henon
Copy link
Collaborator Author

henon commented Feb 26, 2021

Yes, doesn't happen on WASM.
It is not the problem of the debounce. It happens also with non-debounced textfields if you type really fast. I'll try to find a solution once I find the time. We might have to make some changes in MudBaseInput

@bm-evn
Copy link

bm-evn commented Feb 26, 2021

To see it easily, just drop a chunk of text into any autocomplete field on https://mudblazor.com/components/autocomplete and just hold backspace. The cursor goes crazy.

@henon
Copy link
Collaborator Author

henon commented Feb 26, 2021

Textfield the same. It is NOT an autocomplete problem because autocomplete uses the textfield

@mikes-gh mikes-gh added this to the 5.0.4 milestone Mar 1, 2021
@marcmognol
Copy link
Contributor

@henon I just try on mudblazor.com and I have the issue on Autocomplete only.

@mikes-gh
Copy link
Contributor

@Garderoben This is a really annoying widely reported bug which I don't think should be pushed too far into the Future IMO. We should try and fix this as soon as we can.

@henon henon changed the title Textfield swallowing chars when typing rapidly (especially with debouncing 50ms) Textfield swallowing chars when typing rapidly (only on server, not on wasm) Mar 18, 2021
@henon
Copy link
Collaborator Author

henon commented Mar 18, 2021

Since Mike switched our docs server to hybrid (hosted wasm) I can't reproduce it any more, neither for textfield nor for autocomplete.

EDIT: Wrong, I set back to before the change to hybrid and tried with pure server. Can't reproduce it locally!!

@henon
Copy link
Collaborator Author

henon commented Mar 18, 2021

But it still happens on mudblazor.com so this is a bug that is impossible to fix for me. If I can't reproduce locally I can't test whether my changes fix the bug.

EDIT: spoke too soon. It can be reproduced locally by switching to low-tier device in chrome's debugger tools

@henon
Copy link
Collaborator Author

henon commented Mar 18, 2021

I am proud to announce that after 5 hours of tinkering I fixed this with a most elegant solution. The problem was that on slow computers or with high network latency a two-way bound value update coming from a MudInput travelled to the bound partner and came back to the original input which of course had already a newer value due to continued typing. The old value which was travelling and coming back to the sender due to two-way sync, however, then overwrites the new value from the user input. That resulted in seemingly swallowed characters. They were overwritten by a render update of the input.

The solution is simple. I track the focused state of an input by keeping a flag _isFocused which will be set true on input and false if OnBlur fires. While the input is focused it refuses to re-render. That solves the problem and allows the input to be updated by two-way binding in other situations where it is not focused.

@henon henon added the fixed Fix has been merged label Mar 18, 2021
@henon henon modified the milestones: Future, 5.0.7 Mar 18, 2021
@henon
Copy link
Collaborator Author

henon commented Mar 18, 2021

see #1228

@henon henon closed this as completed Mar 18, 2021
henon added a commit that referenced this issue Jul 22, 2021
…1012 #2136)

* wip: numerical input rework

* allow delete

* wip numerical field rework

* NumericField: heed the Culture property inherited by BaseInput

* revert bad numerical input changes

* show spin buttons on nu,erical field

* default hide spin on non numerical inputs

* NumericField: added documentation example

* support inputmode and pattern on inputs

* NumericField: pretty much arrived at the same conclusion as JArleth, up/down arrow keys work now.

* Autocomplete: solved problem that caused test to fail

* MudInput: verified that issue #1012 is not happening any more with text update prevention!

* NumericField: stripping input of invalid chars both in normal and immediate mode

* NumericInput: using arrow up/down keyboard keys will force a value update first

* Moved InputType out of BaseInput

* Moved Clearable out of BaseInput

* Textfield: Added an example for clearable text field

* cleanup debug logs

* NumericField: Fixed up/down keys on BSS (not working at all on WASM)

* NumericField: restricting a hack to BSS (WASM doesn't need it)

* NumericField: allow increment/decrement on wasm

* Nmeric field: support negative values

* NumericField: culture unit test

* NumericField: Cuture test fix

* NumericField: Added an ArrowUp/Down keyboard test

* NumericalField: illegal chars test

* Improved on the illegal chars test

Co-authored-by: Meinrad Recheis <meinrad.recheis@gmail.com>
henon added a commit to henon/MudBlazor that referenced this issue Sep 19, 2021
henon added a commit that referenced this issue Sep 19, 2021
* TextField: added Clear() method which works even while focused

* All inputs: make TextUpdateSuppression configurable (it fixes #1012 but some still want to turn it off)

* BaseInput: made ForceRender() more potent

* TextField: added a test for the TextUpdateSuppression parameter
@mynkow
Copy link

mynkow commented Mar 10, 2023

Still an issue in 2023.

Just paste the following text to try.mudblazor.com

        <MudAutocomplete T="string" Label="Search" @bind-Value="value1" SearchFunc="@Search1"
                         OnKeyUp="test"/>  

@code {
    private string value1;
    private string[] states =
    {
        "Alabama", "Alaska", "American Samoa", "Arizona",
        "Arkansas", "California", "Colorado", "Connecticut",
        "Delaware", "District of Columbia", "Federated States of Micronesia",
        "Florida", "Georgia", "Guam", "Hawaii", "Idaho",
        "Illinois", "Indiana", "Iowa", "Kansas", "Kentucky",
        "Louisiana", "Maine", "Marshall Islands", "Maryland",
        "Massachusetts", "Michigan", "Minnesota", "Mississippi",
        "Missouri", "Montana", "Nebraska", "Nevada",
        "New Hampshire", "New Jersey", "New Mexico", "New York",
        "North Carolina", "North Dakota", "Northern Mariana Islands", "Ohio",
        "Oklahoma", "Oregon", "Palau", "Pennsylvania", "Puerto Rico",
        "Rhode Island", "South Carolina", "South Dakota", "Tennessee",
        "Texas", "Utah", "Vermont", "Virgin Island", "Virginia",
        "Washington", "West Virginia", "Wisconsin", "Wyoming",
    };

    private void test(KeyboardEventArgs e)
    {
        
    }

    private async Task<IEnumerable<string>> Search1(string value)
    {
        // In real life use an asynchronous function for fetching data from an api.
        await Task.Delay(5);

        // if text is null or empty, show complete list
        if (string.IsNullOrEmpty(value))
            return states;
        return states.Where(x => x.Contains(value, StringComparison.InvariantCultureIgnoreCase));
    }
}

@henon
Copy link
Collaborator Author

henon commented Mar 10, 2023

@mynkow no, this is an autocomplete issue not a textfield issue and also it does not happen if you remove the keyup handler so this is an entirely different thing from the original post. Proof: https://try.mudblazor.com/snippet/QumdadbEpZEotNvD

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something does not work as intended/expected fixed Fix has been merged
Projects
None yet
6 participants