Skip to content

Commit 42ef39c

Browse files
author
Alberto Iannaccone
committed
focus on dialog controls when is open
1 parent b3ab5cb commit 42ef39c

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

arduino-ide-extension/src/browser/contributions/user-fields.ts

+5-6
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export class UserFields extends Contribution {
5858
}
5959
}
6060

61-
private selectedFqbnAddress(): string | undefined {
61+
private selectedFqbnAddress(): string | undefined {
6262
const { boardsConfig } = this.boardsServiceProvider;
6363
const fqbn = boardsConfig.selectedBoard?.fqbn;
6464
if (!fqbn) {
@@ -78,7 +78,9 @@ export class UserFields extends Contribution {
7878
): Promise<BoardUserField[] | undefined> {
7979
const cached = this.cachedUserFields.get(key);
8080
// Deep clone the array of board fields to avoid editing the cached ones
81-
this.userFieldsDialog.value = cached ? cached.slice() : await this.boardsServiceProvider.selectedBoardUserFields();
81+
this.userFieldsDialog.value = cached
82+
? cached.slice()
83+
: await this.boardsServiceProvider.selectedBoardUserFields();
8284
const result = await this.userFieldsDialog.open();
8385
if (!result) {
8486
return;
@@ -140,10 +142,7 @@ export class UserFields extends Contribution {
140142
}
141143

142144
notifyFailedWithError(e: Error): void {
143-
if (
144-
this.boardRequiresUserFields &&
145-
CoreError.UploadFailed.is(e)
146-
) {
145+
if (this.boardRequiresUserFields && CoreError.UploadFailed.is(e)) {
147146
this.userFieldsSet = false;
148147
}
149148
}

arduino-ide-extension/src/browser/dialogs/certificate-uploader/certificate-uploader-dialog.tsx

+3
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,9 @@ export class UploadCertificateDialog extends AbstractDialog<void> {
171171
Widget.detach(this.widget);
172172
}
173173
Widget.attach(this.widget, this.contentNode);
174+
const firstButton = this.widget.node.querySelector('button');
175+
firstButton?.focus();
176+
174177
this.widget.busyCallback = this.busyCallback.bind(this);
175178
super.onAfterAttach(msg);
176179
this.update();

arduino-ide-extension/src/browser/dialogs/firmware-uploader/firmware-uploader-dialog.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ export class UploadFirmwareDialog extends AbstractDialog<void> {
115115
Widget.detach(this.widget);
116116
}
117117
Widget.attach(this.widget, this.contentNode);
118+
const firstButton = this.widget.node.querySelector('button');
119+
firstButton?.focus();
118120
this.widget.busyCallback = this.busyCallback.bind(this);
119121
super.onAfterAttach(msg);
120122
this.update();

arduino-ide-extension/src/browser/dialogs/user-fields/user-fields-component.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ export const UserFieldsComponent = ({
7171
field.label
7272
)}
7373
onChange={updateUserField(index)}
74+
autoFocus={index === 0}
7475
/>
7576
</div>
7677
</div>

0 commit comments

Comments
 (0)