fix(browser): cancel trailing debounce timeout on immediate refresh
TimeBasedDebouncer can schedule a trailing setTimeout when refresh requests are throttled. If the debounce window later elapses and an immediate refresh runs, that pending timeout was left armed and could fire afterward, causing a duplicate _innerRefresh (e.g. extra live region updates for screen readers). Clear any pending timeout and reset _additionalRefreshRequested before running the immediate refresh path. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -49,7 +49,12 @@ export class TimeBasedDebouncer implements IRenderDebouncer {
|
||||
// enough time to pass before refreshing again.
|
||||
const refreshRequestTime: number = performance.now();
|
||||
if (refreshRequestTime - this._lastRefreshMs >= this._debounceThresholdMS) {
|
||||
// Enough time has lapsed since the last refresh; refresh immediately
|
||||
// Enough time has elapsed since the last refresh; refresh immediately
|
||||
if (this._refreshTimeoutID !== undefined) {
|
||||
clearTimeout(this._refreshTimeoutID);
|
||||
this._refreshTimeoutID = undefined;
|
||||
this._additionalRefreshRequested = false;
|
||||
}
|
||||
this._lastRefreshMs = refreshRequestTime;
|
||||
this._innerRefresh();
|
||||
} else if (!this._additionalRefreshRequested) {
|
||||
|
||||
Reference in New Issue
Block a user