Skip to content

Commit 0ca1a31

Browse files
Akos Kittakittaakos
Akos Kitta
authored andcommitted
fix: board <select> update on board detach
When the previously selected board is not detected, unset the `<select>` option. Closes #2222 Signed-off-by: Akos Kitta <[email protected]>
1 parent d01f956 commit 0ca1a31

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

Diff for: arduino-ide-extension/src/browser/dialogs/certificate-uploader/certificate-uploader-component.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ export const CertificateUploaderComponent = ({
6969
const onItemSelect = React.useCallback(
7070
(item: BoardOptionValue | null) => {
7171
if (!item) {
72+
setSelectedItem(null);
7273
return;
7374
}
7475
const board = item.board;

Diff for: arduino-ide-extension/src/browser/dialogs/certificate-uploader/select-board-components.tsx

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { nls } from '@theia/core/lib/common';
22
import React from '@theia/core/shared/react';
3-
import type {
4-
BoardList,
5-
BoardListItemWithBoard,
3+
import {
4+
boardListItemEquals,
5+
type BoardList,
6+
type BoardListItemWithBoard,
67
} from '../../../common/protocol/board-list';
78
import { ArduinoSelect } from '../../widgets/arduino-select';
89

@@ -75,7 +76,9 @@ export const SelectBoardComponent = ({
7576
setSelectOptions(boardOptions);
7677

7778
if (selectedItem) {
78-
selBoard = updatableBoards.indexOf(selectedItem);
79+
selBoard = updatableBoards.findIndex((board) =>
80+
boardListItemEquals(board, selectedItem)
81+
);
7982
}
8083

8184
selectOption(boardOptions[selBoard] || null);

Diff for: arduino-ide-extension/src/browser/dialogs/firmware-uploader/firmware-uploader-component.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ export const FirmwareUploaderComponent = ({
104104
const onItemSelect = React.useCallback(
105105
(item: BoardListItemWithBoard | null) => {
106106
if (!item) {
107+
setSelectedItem(null);
107108
return;
108109
}
109110
const board = item.board;

0 commit comments

Comments
 (0)