-
Notifications
You must be signed in to change notification settings - Fork 9.8k
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
Poor typing experience in Blazor Server app when manually binding to oninput event and using Azure SignalR Services #14242
Comments
We can't bend the laws of physics. The issue here is the latency between the event arriving to the server and the data being applied on the client. Blazor server-side is not very well suited to use high frequency events, so the recommendation here is to debounce the event. For example to trigger oninput on the client only after 100 milliseconds of the last event. I think that achieves what most people want. The event being fired without loosing focus from the control and without the jittering that you are observing. I'm not sure what magic incantation we are using to fix it or "correct it" inside "bind". @SteveSandersonMS Is my assesment correct? Do we have a sample for debouncing? |
Yes, @javiercn's assessment is correct. Dan implemented debouncing using a timer in his Weather app, and I also suggested there in a PR how it can be done with a CancellationTokenSource. As for the issue posted here, this is a known limitation of reality and server-side Blazor that we've discussed and designed around in the past, e.g., #8204, #11438. The essence of the issue is a merge conflict: the server says the textbox is changing from The reason that As for improving this further, I've tried to think of ways we could extend the syntax for render output so you can manually associate it with a given incoming event. But I don't see any scenario for it outside two-way binding, and we already have a better syntax for that. Plus it's not an issue at all in client-side Blazor, so it's good to avoid having an entire syntax for things that only make sense in server-side Blazor.
I think this is the real place where we can improve things. In your Weather app scenario, you do in fact have another option, which is to run logic inside a setter, as per my PR. However it would be better still if we didn't have the limitation of one-event-handler-per-event-type-per-element, and instead allowed you to combine |
@javiercn as @danroth27 pointed out, the issue doesn't happen if you don't use the Azure's SignalR service, With websockets only it works fine. So it's not related to a space/time fabric limitation =P |
That's not true I'm afraid. It happens regardless, as it's due to the latency, not due to the transport. |
Yeah, I face palmed a bit when I saw your PR for not thinking of using the property setter solution, but it is a bit off the beaten track. Are we tracking the proposed improvement to allow multiple event handlers per event type somewhere else? |
Filed #14365 |
Repro steps:
@bind
works around the issue.But in my case I need access to the
oninput
event callback to run additional logic.The text was updated successfully, but these errors were encountered: