You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Needs: DesignThis issue requires design work before implementating.Pillar: Technical DebtPriority:1Work that is critical for the release, but we could probably ship withoutaffected-mediumThis issue impacts approximately half of our customersarea-blazorIncludes: Blazor, Razor ComponentsenhancementThis issue represents an ask for new feature or an enhancement to an existing onefeature-blazor-component-modelAny feature that affects the component model for Blazor (Parameters, Rendering, Lifecycle, etc)on-roadmapListed on the current release roadmapseverity-majorThis label is used by an internal tool
This will allow the user to register for scroll events with some time period (100ms) which will filter out events happening within the period, and result in much fewer events being sent to the server.
Reacted by Lee McPherson, Valentin Fritz, Kai Ruhnau, Massimiliano Kraus, Imre Toth, Gianni Angelozzi, Sipke Schoorstra, Braiden Stiller, Jacob Foshee, Majid Iqbal and 66 more
Apart from having a delay, the events should be automatically dispatched, and filtered, depending on the real time the event is taking to be processed in the server(notice the network latency and the time involved in process the request counts).
I asked for this about year ago. Unfortunately the issue was closed with suggestion that I can do it using some JavaScript code. If it will be implemented it should be possible to use throttling and debouncing in all events. Think about resize events, dragging, or input events when you want to implement incremental search and you don't want to query database after each keystroke.
Reacted by Alvaro Rivoir, stavroskasidis, Thomas, Braiden Stiller, Ryouko Konpaku, bugproof, Kerry M-R, ericgrantholland and Will Dean
I think this is a necessary feature to work with many of the events already exposed on Blazor side, especially for ServerSide Blazor. Really don't want OnMouseOver event firing a million times sending Signal R messages at that rate. I know there is a way around this with custom JS but it's a huge hassle. Need to write both JSSetup and JSCleanup for every event you want to handle.
Would be really cool if you could set the interval directly from razor syntax, similar to how stopPropagation and preventDefault work now. See below:
<div @onmouseover="@OnMouseOver" @onmouseover:throttle="160" >
This div mouse over event throttles 160ms
</div>
<div @onmouseover="@OnMouseOver" @onmouseover:debounce="500" >
This div mouse over event debounces 500ms
</div>
Without this level of control, many already exposed events aren't useful in blazor. Fire too often and cause problems.
Reacted by Patrick Jahr, Швырёв Станислав, Stefan, Alexander Zhuravlev, Andreas Vinter-Hviid, Denny09310, Sébastien de Salvador, Kevin Lewis, Jared Thirsk, tommrt and 9 more
I think this is a necessary feature to work with many of the events already exposed on Blazor side, especially for ServerSide Blazor. Really don't want OnMouseOver event firing a million times sending Signal R messages at that rate. I know there is a way around this with custom JS but it's a huge hassle. Need to write both JSSetup and JSCleanup for every event you want to handle.
Would be really cool if you could set the interval directly from razor syntax, similar to how stopPropagation and preventDefault work now. See below:
<div @onmouseover="@OnMouseOver" @onmouseover:throttle="160" >
This div mouse over event throttles 160ms
</div>
<div @onmouseover="@OnMouseOver" @onmouseover:debounce="500" >
This div mouse over event debounces 500ms
</div>
Without this level of control, many already exposed events aren't useful in blazor. Fire too often and cause problems.
Agreed that having to do some custom setup to handle this is a hassle.
Something like the suggested solution would be fantastic!
Glad to see debouncing on the roadmap for .NET 11; we use Blazor at Penn State, and a built-in way to debounce text input in particular would be very helpful.
We are looking into adding a built-in support for rate limiting events on the client. I did some research on the related UX patterns, similar features in other frameworks, and possible pitfalls. The following specification draft describes a design with behavioral choices informed by that context. All feedback is welcome.
Main scenarios
Incremental text input and live search: Delaying oninput (either directly or with @bind:event="oninput") until the user pauses typing for a short interval (such as 300ms) so the app does not query a backend or re-render on every keystroke.
High-frequency continuous interactions: Rate-limiting onscroll, onmousemove, onpointermove, ontouchmove, ondrag, onwheel, or range slider oninput events so the component receives periodic progress updates without flooding the SignalR circuit or WebAssembly runtime, while still receiving the final position or value when movement stops.
Action rate-limiting and double-click prevention: Preventing rapid repeated triggers on discrete actions such as button onclick or held-down onkeydown events.
Syntax
Debounce and throttle are configured as directive attribute parameters on DOM events using an explicit millisecond interval (int):
The value is an integer representing milliseconds. A value of 0 or less disables rate-limiting, allowing dynamic expressions (for example, @oninput:debounce="@debounceMs").
Both :debounce and :throttle are opt-in per event and disabled by default to preserve backwards compatibility.
Specifying both :debounce and :throttle on the same event of the same element is a compile-time error.
Event classification: Discrete vs. Continuous
When it comes to expectations for when exactly should debounced or throttled DOM events fire to capture the user's intent, there are two types of events:
Continuous events represent ongoing state or position changes where the final value matters:
Input and selection: oninput, onselect, onselectionchange
Pointer, mouse, and touch movement: onmousemove, onpointermove, ontouchmove, onwheel, onmousewheel
Dragging and scrolling: ondrag, ondragover, onscroll
Media and progress: ontimeupdate, onprogress, onseeking, onvolumechange, onratechange
Discrete events represent distinct point-in-time actions or transitions:
All other built-in events, including onclick, ondblclick, onmousedown, onmouseup, onkeydown, onkeyup, onkeypress, onchange, onsubmit, onfocus, onblur, ondragstart, ondragend, ondrop, etc.
Custom events registered by developers or libraries can explicitly specify whether they use discrete or continuous semantics (defaulting to discrete if unspecified).
Timing semantics
Debounce (@on{EVENT}:debounce="ms")
Both discrete and continuous events use trailing-edge debounce.
When the event fires, a timer for ms milliseconds starts. If the same event fires again on the same element before the timer expires, the previous pending event is replaced with the new one and the timer resets.
The event is dispatched to .NET only after ms milliseconds have elapsed without another occurrence.
Throttle (@on{EVENT}:throttle="ms")
Discrete events use leading-only throttle.
The first event is dispatched immediately and starts an ms cooldown window.
Any further occurrences of that event on the element during the cooldown window are ignored. No trailing event fires when the window ends.
Continuous events use leading + trailing throttle.
The first event is dispatched immediately and starts an ms cooldown window.
If one or more occurrences happen during the cooldown window, only the latest one is retained and dispatched when the cooldown window ends, which starts a new cooldown window.
This guarantees that the component always receives the final scroll offset, cursor position, or slider value when the user stops moving.
Behavioral guarantees and edge cases
Flushing pending events to preserve ordering:
If an element has a pending debounced or trailing-throttled event (such as oninput), and the element loses focus (blur), commits its value (change), or any non-delayed event in the document (such as submit, click, or an un-delayed keydown) is about to be dispatched to .NET, all pending delayed events are flushed and dispatched immediately first, and their timers are cancelled.
For throttled onkeydown / onkeypress, releasing the key (keyup) resets the throttle cooldown so a subsequent intentional key press is not dropped.
Synchronous preventDefault and stopPropagation:
When :preventDefault or :stopPropagation is used alongside :debounce or :throttle, the browser's default action or propagation is stopped synchronously on every raw DOM event as it happens, even when the .NET callback dispatch is delayed or dropped.
Capturing event state at occurrence time:
Event arguments and input values are captured synchronously when the browser raises the DOM event, not when the timer later expires.
Protecting live user input during re-renders:
While an element has an active debounced or throttled input update waiting to be processed, intermediate component re-renders must not overwrite the user's in-progress DOM input value or reset the caret position with stale state.
Component re-renders and disposal:
If a component re-renders and replaces the delegate for an event while a timer is pending, the pending timer dispatches to the updated handler when it fires.
If the event handler or DOM element is removed, or the component is disposed, any pending timer for it is cancelled immediately and never dispatches to .NET.
Needs: DesignThis issue requires design work before implementating.Pillar: Technical DebtPriority:1Work that is critical for the release, but we could probably ship withoutaffected-mediumThis issue impacts approximately half of our customersarea-blazorIncludes: Blazor, Razor ComponentsenhancementThis issue represents an ask for new feature or an enhancement to an existing onefeature-blazor-component-modelAny feature that affects the component model for Blazor (Parameters, Rendering, Lifecycle, etc)on-roadmapListed on the current release roadmapseverity-majorThis label is used by an internal tool
Activity
arivoir commentedon May 24, 2019
Apart from having a delay, the events should be automatically dispatched, and filtered, depending on the real time the event is taking to be processed in the server(notice the network latency and the time involved in process the request counts).
Something like this
Andrzej-W commentedon May 27, 2019
I asked for this about year ago. Unfortunately the issue was closed with suggestion that I can do it using some JavaScript code. If it will be implemented it should be possible to use throttling and debouncing in all events. Think about resize events, dragging, or input events when you want to implement incremental search and you don't want to query database after each keystroke.
ctrl-alt-d commentedon Aug 18, 2019
Maybe you can use a Timer as workaround.
55 remaining items
ericgrantholland commentedon Mar 21, 2024
I think this is a necessary feature to work with many of the events already exposed on Blazor side, especially for ServerSide Blazor. Really don't want OnMouseOver event firing a million times sending Signal R messages at that rate. I know there is a way around this with custom JS but it's a huge hassle. Need to write both JSSetup and JSCleanup for every event you want to handle.
Would be really cool if you could set the interval directly from razor syntax, similar to how stopPropagation and preventDefault work now. See below:
Without this level of control, many already exposed events aren't useful in blazor. Fire too often and cause problems.
MrDach commentedon Feb 11, 2025
Agreed that having to do some custom setup to handle this is a hassle.
Something like the suggested solution would be fantastic!
jvs7315 commentedon Apr 2, 2026
Glad to see debouncing on the roadmap for .NET 11; we use Blazor at Penn State, and a built-in way to debounce text input in particular would be very helpful.
oroztocil commentedon Nov 4, 2026
We are looking into adding a built-in support for rate limiting events on the client. I did some research on the related UX patterns, similar features in other frameworks, and possible pitfalls. The following specification draft describes a design with behavioral choices informed by that context. All feedback is welcome.
Main scenarios
oninput(either directly or with@bind:event="oninput") until the user pauses typing for a short interval (such as 300ms) so the app does not query a backend or re-render on every keystroke.onscroll,onmousemove,onpointermove,ontouchmove,ondrag,onwheel, or range slideroninputevents so the component receives periodic progress updates without flooding the SignalR circuit or WebAssembly runtime, while still receiving the final position or value when movement stops.onclickor held-downonkeydownevents.Syntax
Debounce and throttle are configured as directive attribute parameters on DOM events using an explicit millisecond interval (
int):0or less disables rate-limiting, allowing dynamic expressions (for example,@oninput:debounce="@debounceMs").:debounceand:throttleare opt-in per event and disabled by default to preserve backwards compatibility.:debounceand:throttleon the same event of the same element is a compile-time error.Event classification: Discrete vs. Continuous
When it comes to expectations for when exactly should debounced or throttled DOM events fire to capture the user's intent, there are two types of events:
oninput,onselect,onselectionchangeonmousemove,onpointermove,ontouchmove,onwheel,onmousewheelondrag,ondragover,onscrollontimeupdate,onprogress,onseeking,onvolumechange,onratechangeonclick,ondblclick,onmousedown,onmouseup,onkeydown,onkeyup,onkeypress,onchange,onsubmit,onfocus,onblur,ondragstart,ondragend,ondrop, etc.Custom events registered by developers or libraries can explicitly specify whether they use discrete or continuous semantics (defaulting to discrete if unspecified).
Timing semantics
Debounce (
@on{EVENT}:debounce="ms")msmilliseconds starts. If the same event fires again on the same element before the timer expires, the previous pending event is replaced with the new one and the timer resets.msmilliseconds have elapsed without another occurrence.Throttle (
@on{EVENT}:throttle="ms")mscooldown window.mscooldown window.Behavioral guarantees and edge cases
oninput), and the element loses focus (blur), commits its value (change), or any non-delayed event in the document (such assubmit,click, or an un-delayedkeydown) is about to be dispatched to .NET, all pending delayed events are flushed and dispatched immediately first, and their timers are cancelled.onkeydown/onkeypress, releasing the key (keyup) resets the throttle cooldown so a subsequent intentional key press is not dropped.preventDefaultandstopPropagation::preventDefaultor:stopPropagationis used alongside:debounceor:throttle, the browser's default action or propagation is stopped synchronously on every raw DOM event as it happens, even when the .NET callback dispatch is delayed or dropped.Prototype
Prototype PRs implementing this spec: