relayout color picker on hover content change (#255335)

relayout color picker on content change
This commit is contained in:
Aiday Marlen Kyzy
2025-07-11 10:20:55 +00:00
committed by GitHub
parent dcb4e12e34
commit e45fddacfc
5 changed files with 19 additions and 9 deletions
@@ -53,10 +53,6 @@ export class SaturationBox extends Disposable {
return this._domNode;
}
public get canvas() {
return this._canvas;
}
private onPointerDown(e: PointerEvent): void {
if (!e.target || !(e.target instanceof Element)) {
return;
@@ -156,6 +156,10 @@ export class HoverColorPickerParticipant implements IEditorHoverParticipant<Colo
this._colorPicker?.layout();
}
public handleContentsChanged(): void {
this._colorPicker?.layout();
}
public handleHide(): void {
this._colorPicker?.dispose();
this._colorPicker = undefined;
@@ -41,6 +41,9 @@ export class ContentHoverWidget extends ResizableContentWidget {
private readonly _onDidScroll = this._register(new Emitter<ScrollEvent>());
public readonly onDidScroll = this._onDidScroll.event;
private readonly _onContentsChanged = this._register(new Emitter<void>());
public readonly onContentsChanged = this._onContentsChanged.event;
public get isVisibleFromKeyboard(): boolean {
return (this._renderedHover?.source === HoverStartSource.Keyboard);
}
@@ -311,7 +314,7 @@ export class ContentHoverWidget extends ResizableContentWidget {
this._setRenderedHover(renderedHover);
this._updateFont();
this._updateContent(renderedHover.domNode);
this.onContentsChanged();
this.handleContentsChanged();
// Simply force a synchronous render on the editor
// such that the widget does not really render with left = '0px'
this._editor.render();
@@ -340,7 +343,7 @@ export class ContentHoverWidget extends ResizableContentWidget {
// See https://github.com/microsoft/vscode/issues/140339
// TODO: Doing a second layout of the hover after force rendering the editor
this.onContentsChanged();
this.handleContentsChanged();
if (renderedHover.shouldFocus) {
this._hover.containerDomNode.focus();
}
@@ -399,7 +402,7 @@ export class ContentHoverWidget extends ResizableContentWidget {
this._resizableNode.minSize = new dom.Dimension(width, this._minimumSize.height);
}
public onContentsChanged(): void {
public handleContentsChanged(): void {
this._removeConstraintsRenderNormally();
const contentsDomNode = this._hover.contentsDomNode;
@@ -420,6 +423,7 @@ export class ContentHoverWidget extends ResizableContentWidget {
this._positionPreference = this._findPositionPreference(widgetHeight, this._renderedHover.showAtPosition);
}
this._layoutContentWidget();
this._onContentsChanged.fire();
}
public focus(): void {
@@ -61,6 +61,9 @@ export class ContentHoverWidgetWrapper extends Disposable implements IHoverWidge
this._register(this._contentHoverWidget.onDidScroll((e) => {
this._participants.forEach(participant => participant.handleScroll?.(e));
}));
this._register(this._contentHoverWidget.onContentsChanged(() => {
this._participants.forEach(participant => participant.handleContentsChanged?.());
}));
return participants;
}
@@ -83,6 +86,9 @@ export class ContentHoverWidgetWrapper extends Disposable implements IHoverWidge
this._setCurrentResult(this._currentResult); // render again
}
}));
this._register(this._contentHoverWidget.onContentsChanged(() => {
this._onContentsChanged.fire();
}));
}
/**
@@ -228,8 +234,7 @@ export class ContentHoverWidgetWrapper extends Disposable implements IHoverWidge
this.hide();
};
const onContentsChanged = () => {
this._onContentsChanged.fire();
this._contentHoverWidget.onContentsChanged();
this._contentHoverWidget.handleContentsChanged();
};
const setMinimumDimensions = (dimensions: dom.Dimension) => {
this._contentHoverWidget.setMinimumDimensions(dimensions);
@@ -169,6 +169,7 @@ export interface IEditorHoverParticipant<T extends IHoverPart = IHoverPart> {
getAccessibleContent(hoverPart: T): string;
handleResize?(): void;
handleHide?(): void;
handleContentsChanged?(): void;
handleScroll?(e: ScrollEvent): void;
}