Skip to content

Commit 867f017

Browse files
committed
1 parent 12b4451 commit 867f017

5 files changed

Lines changed: 32 additions & 10 deletions

File tree

src/vs/base/browser/ui/contextview/contextview.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
.context-view {
7-
position: absolute;
7+
position: fixed;
88
z-index: 2500;
99
}

src/vs/base/browser/ui/contextview/contextview.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export interface IDelegate {
3838
}
3939

4040
export interface IContextViewProvider {
41-
showContextView(delegate: IDelegate): void;
41+
showContextView(delegate: IDelegate, container?: HTMLElement): void;
4242
hideContextView(): void;
4343
layout(): void;
4444
}
@@ -255,9 +255,8 @@ export class ContextView extends Disposable {
255255
DOM.addClass(this.view, anchorPosition === AnchorPosition.BELOW ? 'bottom' : 'top');
256256
DOM.addClass(this.view, anchorAlignment === AnchorAlignment.LEFT ? 'left' : 'right');
257257

258-
const containerPosition = DOM.getDomNodePagePosition(this.container!);
259-
this.view.style.top = `${top - containerPosition.top}px`;
260-
this.view.style.left = `${left - containerPosition.left}px`;
258+
this.view.style.top = `${top}px`;
259+
this.view.style.left = `${left}px`;
261260
this.view.style.width = 'initial';
262261
}
263262

src/vs/base/browser/ui/selectBox/selectBox.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,9 @@
66
.monaco-select-box {
77
width: 100%;
88
}
9+
10+
.monaco-select-box-dropdown-container {
11+
font-size: 13px;
12+
font-weight: normal;
13+
text-transform: none;
14+
}

src/vs/base/browser/ui/selectBox/selectBoxCustom.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ export class SelectBoxList extends Disposable implements ISelectBoxDelegate, ILi
8989
private _isVisible: boolean;
9090
private selectBoxOptions: ISelectBoxOptions;
9191
private selectElement: HTMLSelectElement;
92+
private container?: HTMLElement;
9293
private options: ISelectOptionItem[] = [];
9394
private selected: number;
9495
private readonly _onDidSelect: Emitter<ISelectData>;
@@ -307,6 +308,7 @@ export class SelectBoxList extends Disposable implements ISelectBoxDelegate, ILi
307308
}
308309

309310
public render(container: HTMLElement): void {
311+
this.container = container;
310312
dom.addClass(container, 'select-container');
311313
container.appendChild(this.selectElement);
312314
this.applyStyles();
@@ -442,7 +444,7 @@ export class SelectBoxList extends Disposable implements ISelectBoxDelegate, ILi
442444
dom.toggleClass(this.selectElement, 'synthetic-focus', false);
443445
},
444446
anchorPosition: this._dropDownPosition
445-
});
447+
}, this.container);
446448

447449
// Hide so we can relay out
448450
this._isVisible = true;
@@ -457,7 +459,7 @@ export class SelectBoxList extends Disposable implements ISelectBoxDelegate, ILi
457459
dom.toggleClass(this.selectElement, 'synthetic-focus', false);
458460
},
459461
anchorPosition: this._dropDownPosition
460-
});
462+
}, this.container);
461463

462464
// Track initial selection the case user escape, blur
463465
this._currentSelection = this.selected;

src/vs/platform/contextview/browser/contextViewService.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@ export class ContextViewService extends Disposable implements IContextViewServic
1212
_serviceBrand: undefined;
1313

1414
private contextView: ContextView;
15+
private container: HTMLElement;
1516

1617
constructor(
1718
@ILayoutService readonly layoutService: ILayoutService
1819
) {
1920
super();
2021

21-
this.contextView = this._register(new ContextView(layoutService.container));
22+
this.container = layoutService.container;
23+
this.contextView = this._register(new ContextView(this.container));
2224
this.layout();
2325

2426
this._register(layoutService.onLayout(() => this.layout()));
@@ -30,7 +32,20 @@ export class ContextViewService extends Disposable implements IContextViewServic
3032
this.contextView.setContainer(container);
3133
}
3234

33-
showContextView(delegate: IContextViewDelegate): void {
35+
showContextView(delegate: IContextViewDelegate, container?: HTMLElement): void {
36+
37+
if (container) {
38+
if (container !== this.container) {
39+
this.container = container;
40+
this.setContainer(container);
41+
}
42+
} else {
43+
if (this.container !== this.layoutService.container) {
44+
this.container = this.layoutService.container;
45+
this.setContainer(this.container);
46+
}
47+
}
48+
3449
this.contextView.show(delegate);
3550
}
3651

@@ -41,4 +56,4 @@ export class ContextViewService extends Disposable implements IContextViewServic
4156
hideContextView(data?: any): void {
4257
this.contextView.hide(data);
4358
}
44-
}
59+
}

0 commit comments

Comments
 (0)