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 <a.kitta@arduino.cc>
This commit is contained in:
Akos Kitta
2023-11-22 16:33:01 +01:00
committed by Akos Kitta
parent d01f95647e
commit 0ca1a31747
3 changed files with 9 additions and 4 deletions

View File

@@ -1,8 +1,9 @@
import { nls } from '@theia/core/lib/common';
import React from '@theia/core/shared/react';
import type {
BoardList,
BoardListItemWithBoard,
import {
boardListItemEquals,
type BoardList,
type BoardListItemWithBoard,
} from '../../../common/protocol/board-list';
import { ArduinoSelect } from '../../widgets/arduino-select';
@@ -75,7 +76,9 @@ export const SelectBoardComponent = ({
setSelectOptions(boardOptions);
if (selectedItem) {
selBoard = updatableBoards.indexOf(selectedItem);
selBoard = updatableBoards.findIndex((board) =>
boardListItemEquals(board, selectedItem)
);
}
selectOption(boardOptions[selBoard] || null);