Skip to content

Commit c975752

Browse files
committed
1 parent 57f3bc1 commit c975752

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

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

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,14 @@ export class Dialog extends Disposable {
9999
let focusedButton = 0;
100100
const buttonGroup = this.buttonGroup = new ButtonGroup(this.buttonsContainer, this.buttons.length, { title: true });
101101
const buttonMap = this.rearrangeButtons(this.buttons, this.options.cancelId);
102+
103+
// Set focused button to UI index
104+
buttonMap.forEach((value, index) => {
105+
if (value.index === 0) {
106+
focusedButton = index;
107+
}
108+
});
109+
102110
buttonGroup.buttons.forEach((button, index) => {
103111
button.label = mnemonicButtonLabel(buttonMap[index].label, true);
104112

@@ -190,11 +198,7 @@ export class Dialog extends Disposable {
190198
show(this.element);
191199

192200
// Focus first element
193-
buttonMap.forEach((value, index) => {
194-
if (value.index === focusedButton) {
195-
buttonGroup.buttons[index].focus();
196-
}
197-
});
201+
buttonGroup.buttons[focusedButton].focus();
198202
});
199203
}
200204

0 commit comments

Comments
 (0)