mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 04:49:35 +00:00
Custom hovers for input box except when focused (#206873)
Customhovers for inputbox but not when focused
This commit is contained in:
parent
e09633b182
commit
6c9d5b3df6
|
@ -270,7 +270,14 @@ export function setupCustomHover(hoverDelegate: IHoverDelegate, htmlElement: HTM
|
|||
toDispose.add(triggerShowHover(hoverDelegate.delay, false, target));
|
||||
hoverPreparation = toDispose;
|
||||
};
|
||||
const focusDomEmitter = dom.addDisposableListener(htmlElement, dom.EventType.FOCUS, onFocus, true);
|
||||
|
||||
// Do not show hover when focusing an input or textarea
|
||||
let focusDomEmitter: undefined | IDisposable;
|
||||
const tagName = htmlElement.tagName.toLowerCase();
|
||||
if (tagName !== 'input' && tagName !== 'textarea') {
|
||||
focusDomEmitter = dom.addDisposableListener(htmlElement, dom.EventType.FOCUS, onFocus, true);
|
||||
}
|
||||
|
||||
const hover: ICustomHover = {
|
||||
show: focus => {
|
||||
hideHover(false, true); // terminate a ongoing mouse over preparation
|
||||
|
@ -288,7 +295,7 @@ export function setupCustomHover(hoverDelegate: IHoverDelegate, htmlElement: HTM
|
|||
mouseLeaveEmitter.dispose();
|
||||
mouseDownEmitter.dispose();
|
||||
mouseUpEmitter.dispose();
|
||||
focusDomEmitter.dispose();
|
||||
focusDomEmitter?.dispose();
|
||||
hideHover(true, true);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -11,6 +11,8 @@ import { MarkdownRenderOptions } from 'vs/base/browser/markdownRenderer';
|
|||
import { ActionBar } from 'vs/base/browser/ui/actionbar/actionbar';
|
||||
import * as aria from 'vs/base/browser/ui/aria/aria';
|
||||
import { AnchorAlignment, IContextViewProvider } from 'vs/base/browser/ui/contextview/contextview';
|
||||
import { getDefaultHoverDelegate } from 'vs/base/browser/ui/hover/hoverDelegateFactory';
|
||||
import { ICustomHover, setupCustomHover } from 'vs/base/browser/ui/hover/updatableHoverWidget';
|
||||
import { ScrollableElement } from 'vs/base/browser/ui/scrollbar/scrollableElement';
|
||||
import { Widget } from 'vs/base/browser/ui/widget';
|
||||
import { IAction } from 'vs/base/common/actions';
|
||||
|
@ -111,6 +113,7 @@ export class InputBox extends Widget {
|
|||
private cachedContentHeight: number | undefined;
|
||||
private maxHeight: number = Number.POSITIVE_INFINITY;
|
||||
private scrollableElement: ScrollableElement | undefined;
|
||||
private hover: ICustomHover | undefined;
|
||||
|
||||
private _onDidChange = this._register(new Emitter<string>());
|
||||
public readonly onDidChange: Event<string> = this._onDidChange.event;
|
||||
|
@ -230,7 +233,11 @@ export class InputBox extends Widget {
|
|||
|
||||
public setTooltip(tooltip: string): void {
|
||||
this.tooltip = tooltip;
|
||||
this.input.title = tooltip;
|
||||
if (!this.hover) {
|
||||
this.hover = this._register(setupCustomHover(getDefaultHoverDelegate('mouse'), this.input, tooltip));
|
||||
} else {
|
||||
this.hover.update(tooltip);
|
||||
}
|
||||
}
|
||||
|
||||
public setAriaLabel(label: string): void {
|
||||
|
|
Loading…
Reference in a new issue