Skip to content

Commit b5f77d1

Browse files
author
Justin Chen
committed
fixed more styling and dom focus on widget
1 parent 1b8e06a commit b5f77d1

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

src/vs/editor/contrib/codeAction/browser/codeActionMenu.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ export class CodeActionMenu extends Disposable implements IEditorContribution {
146146
private focusedEnabledItem: number | undefined;
147147
private currSelectedItem: number = 0;
148148
private hasSeperator: boolean = false;
149+
private block: HTMLElement | null = null;
149150

150151
public static readonly ID: string = 'editor.contrib.codeActionMenu';
151152

@@ -203,6 +204,21 @@ export class CodeActionMenu extends Disposable implements IEditorContribution {
203204
const renderDisposables = new DisposableStore();
204205
const renderMenu = document.createElement('div');
205206

207+
// Render invisible div to block mouse interaction in the rest of the UI
208+
const menuBlock = document.createElement('div');
209+
this.block = element.appendChild(menuBlock);
210+
this.block.classList.add('context-view-block');
211+
this.block.style.position = 'fixed';
212+
this.block.style.cursor = 'initial';
213+
this.block.style.left = '0';
214+
this.block.style.top = '0';
215+
this.block.style.width = '100%';
216+
this.block.style.height = '100%';
217+
this.block.style.zIndex = '-1';
218+
219+
// TODO@Steven: this is never getting disposed
220+
dom.addDisposableListener(this.block, dom.EventType.MOUSE_DOWN, e => e.stopPropagation());
221+
206222
renderMenu.id = 'codeActionMenuWidget';
207223
renderMenu.classList.add('codeActionMenuWidget');
208224

@@ -267,9 +283,19 @@ export class CodeActionMenu extends Disposable implements IEditorContribution {
267283
this.currSelectedItem = this.viewItems[0].index;
268284
this.codeActionList.value.setFocus([this.currSelectedItem]);
269285

286+
287+
// const focusTracker = this._register(dom.trackFocus(element));
288+
// this._register(focusTracker.onDidBlur(() => {
289+
// if (dom.getActiveElement() === element || !dom.isAncestor(dom.getActiveElement(), element)) {
290+
// this.hideCodeActionWidget();
291+
// }
292+
// }));
293+
270294
// List Focus
271295
this.codeActionList.value.domFocus();
272296
const focusTracker = dom.trackFocus(element);
297+
298+
element.focus();
273299
const blurListener = focusTracker.onDidBlur(() => {
274300
this.hideCodeActionWidget();
275301
// this._contextViewService.hideContextView({ source: this });

src/vs/editor/contrib/codeAction/browser/media/action.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
border-color: none;
1919
background-color: var(--vscode-menu-background);
2020
color: var(--vscode-menu-foreground);
21+
box-shadow: rgb(0,0,0, 16%) 0px 2px 8px;
2122
}
2223

2324
.codeActionMenuWidget .monaco-list:not(.element-focused):focus:before {

0 commit comments

Comments
 (0)