mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-24 10:38:59 +01:00
Fix #83599. Refresh code widget focus state when hide
This commit is contained in:
@@ -972,6 +972,7 @@ export const EventHelper = {
|
||||
export interface IFocusTracker extends Disposable {
|
||||
onDidFocus: Event<void>;
|
||||
onDidBlur: Event<void>;
|
||||
refreshState?(): void;
|
||||
}
|
||||
|
||||
export function saveParentsScrollTop(node: Element): number[] {
|
||||
@@ -1000,6 +1001,8 @@ class FocusTracker extends Disposable implements IFocusTracker {
|
||||
private readonly _onDidBlur = this._register(new Emitter<void>());
|
||||
public readonly onDidBlur: Event<void> = this._onDidBlur.event;
|
||||
|
||||
private _refreshStateHandler: () => void;
|
||||
|
||||
constructor(element: HTMLElement | Window) {
|
||||
super();
|
||||
let hasFocus = isAncestor(document.activeElement, <HTMLElement>element);
|
||||
@@ -1026,9 +1029,24 @@ class FocusTracker extends Disposable implements IFocusTracker {
|
||||
}
|
||||
};
|
||||
|
||||
this._refreshStateHandler = () => {
|
||||
let currentNodeHasFocus = isAncestor(document.activeElement, <HTMLElement>element);
|
||||
if (currentNodeHasFocus !== hasFocus) {
|
||||
if (hasFocus) {
|
||||
onBlur();
|
||||
} else {
|
||||
onFocus();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
this._register(domEvent(element, EventType.FOCUS, true)(onFocus));
|
||||
this._register(domEvent(element, EventType.BLUR, true)(onBlur));
|
||||
}
|
||||
|
||||
refreshState() {
|
||||
this._refreshStateHandler();
|
||||
}
|
||||
}
|
||||
|
||||
export function trackFocus(element: HTMLElement | Window): IFocusTracker {
|
||||
|
||||
Reference in New Issue
Block a user