Skip to content

Commit 428c8e2

Browse files
authored
SCM - More focus related fixes to the commit action button (microsoft#154087)
More focus related fixes to the commit action button
1 parent cdc1920 commit 428c8e2

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

src/vs/base/browser/ui/list/listWidget.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,22 @@ export function isMonacoEditor(e: HTMLElement): boolean {
258258
return isMonacoEditor(e.parentElement);
259259
}
260260

261+
export function isButton(e: HTMLElement): boolean {
262+
if (e.tagName === 'A' && e.classList.contains('monaco-button')) {
263+
return true;
264+
}
265+
266+
if (e.classList.contains('monaco-list')) {
267+
return false;
268+
}
269+
270+
if (!e.parentElement) {
271+
return false;
272+
}
273+
274+
return isButton(e.parentElement);
275+
}
276+
261277
class KeyboardController<T> implements IDisposable {
262278

263279
private readonly disposables = new DisposableStore();

src/vs/base/browser/ui/tree/abstractTree.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { DomEmitter } from 'vs/base/browser/event';
99
import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
1010
import { IIdentityProvider, IKeyboardNavigationDelegate, IKeyboardNavigationLabelProvider, IListContextMenuEvent, IListDragAndDrop, IListDragOverReaction, IListMouseEvent, IListRenderer, IListVirtualDelegate } from 'vs/base/browser/ui/list/list';
1111
import { ElementsDragAndDropData } from 'vs/base/browser/ui/list/listView';
12-
import { DefaultKeyboardNavigationDelegate, IListOptions, IListStyles, isInputElement, isMonacoEditor, List, MouseController } from 'vs/base/browser/ui/list/listWidget';
12+
import { DefaultKeyboardNavigationDelegate, IListOptions, IListStyles, isButton, isInputElement, isMonacoEditor, List, MouseController } from 'vs/base/browser/ui/list/listWidget';
1313
import { getVisibleState, isFilterResult } from 'vs/base/browser/ui/tree/indexTreeModel';
1414
import { ICollapseStateChangeEvent, ITreeContextMenuEvent, ITreeDragAndDrop, ITreeEvent, ITreeFilter, ITreeModel, ITreeModelSpliceEvent, ITreeMouseEvent, ITreeNavigator, ITreeNode, ITreeRenderer, TreeDragOverBubble, TreeError, TreeFilterResult, TreeMouseEventTarget, TreeVisibility } from 'vs/base/browser/ui/tree/tree';
1515
import { distinct, equals, firstOrDefault, range } from 'vs/base/common/arrays';
@@ -1153,7 +1153,9 @@ class TreeNodeListMouseController<T, TFilterData, TRef> extends MouseController<
11531153
}
11541154

11551155
protected override onViewPointer(e: IListMouseEvent<ITreeNode<T, TFilterData>>): void {
1156-
if (isInputElement(e.browserEvent.target as HTMLElement) || isMonacoEditor(e.browserEvent.target as HTMLElement)) {
1156+
if (isButton(e.browserEvent.target as HTMLElement) ||
1157+
isInputElement(e.browserEvent.target as HTMLElement) ||
1158+
isMonacoEditor(e.browserEvent.target as HTMLElement)) {
11571159
return;
11581160
}
11591161

src/vs/workbench/contrib/scm/browser/scmViewPane.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2400,6 +2400,7 @@ export class SCMViewPane extends ViewPane {
24002400

24012401
if (widget) {
24022402
widget.focus();
2403+
this.tree.setFocus([], e.browserEvent);
24032404

24042405
const selection = this.tree.getSelection();
24052406

@@ -2416,6 +2417,7 @@ export class SCMViewPane extends ViewPane {
24162417
const target = e.browserEvent?.target as HTMLElement;
24172418
if (target.classList.contains('monaco-tl-row') || target.classList.contains('button-container')) {
24182419
this.actionButtonRenderer.focusActionButton(e.element);
2420+
this.tree.setFocus([], e.browserEvent);
24192421
}
24202422

24212423
return;

0 commit comments

Comments
 (0)