Skip to content

Commit

Permalink
Merge pull request #199220 from microsoft/merogge/tooltip-on-keyboard…
Browse files Browse the repository at this point in the history
…-focus

show tooltip on icon label keyboard focus
  • Loading branch information
meganrogge authored Nov 27, 2023
2 parents d25e484 + 9af553d commit fccd478
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/vs/base/browser/ui/iconLabel/iconLabelHover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,22 @@ export function setupCustomHover(hoverDelegate: IHoverDelegate, htmlElement: HTM
hoverPreparation = toDispose;
};
const mouseOverDomEmitter = dom.addDisposableListener(htmlElement, dom.EventType.MOUSE_OVER, onMouseOver, true);

const onFocus = () => {
if (hoverPreparation) {
return;
}
const target: IHoverDelegateTarget = {
targetElements: [htmlElement],
dispose: () => { }
};
const toDispose: DisposableStore = new DisposableStore();
const onBlur = () => hideHover(true, true);
toDispose.add(dom.addDisposableListener(htmlElement, dom.EventType.BLUR, onBlur, true));
toDispose.add(triggerShowHover(hoverDelegate.delay, false, target));
hoverPreparation = toDispose;
};
const focusDomEmitter = dom.addDisposableListener(htmlElement, dom.EventType.FOCUS, onFocus, true);
const hover: ICustomHover = {
show: focus => {
hideHover(false, true); // terminate a ongoing mouse over preparation
Expand All @@ -233,6 +249,7 @@ export function setupCustomHover(hoverDelegate: IHoverDelegate, htmlElement: HTM
},
dispose: () => {
mouseOverDomEmitter.dispose();
focusDomEmitter.dispose();
hideHover(true, true);
}
};
Expand Down

0 comments on commit fccd478

Please sign in to comment.